]> granicus.if.org Git - strace/commitdiff
printflags: handle empty xlats
authorMike Frysinger <vapier@gentoo.org>
Sat, 31 Oct 2015 04:47:59 +0000 (00:47 -0400)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 16 Nov 2015 03:08:41 +0000 (03:08 +0000)
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

diff --git a/util.c b/util.c
index c3e3fdaf9a2180699123af4ad2241f59850b9825..5f1f733e4d4be076df7f475e0504b4cc8fd30ab5 100644 (file)
--- a/util.c
+++ b/util.c
@@ -352,7 +352,7 @@ printflags(const struct xlat *xlat, int flags, const char *dflt)
        int n;
        const char *sep;
 
-       if (flags == 0 && xlat->val == 0) {
+       if (flags == 0 && xlat->val == 0 && xlat->str) {
                tprints(xlat->str);
                return 1;
        }