[PATCH] printflags: handle empty xlats

Mike Frysinger vapier at gentoo.org
Sat Oct 31 04:47:59 UTC 2015


If the set of headers are unable to produce a valid list, printflags
will try to pass NULL to tprints which crashes.  Add a sanity check
for this edge case.

* util.c (printflags): Check xlat->str is not NULL.
---
 util.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/util.c b/util.c
index c3e3fda..7c19044 100644
--- a/util.c
+++ b/util.c
@@ -353,8 +353,11 @@ printflags(const struct xlat *xlat, int flags, const char *dflt)
 	const char *sep;
 
 	if (flags == 0 && xlat->val == 0) {
-		tprints(xlat->str);
-		return 1;
+		if (xlat->str) {
+			tprints(xlat->str);
+			return 1;
+		} else
+			return 0;
 	}
 
 	sep = "";
-- 
2.5.2





More information about the Strace-devel mailing list