]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Add null check to placate static analysis tools
authorMartin Kittel <martin.kittel@sap.com>
Wed, 29 Mar 2017 07:22:18 +0000 (09:22 +0200)
committerGreg Hudson <ghudson@mit.edu>
Wed, 29 Mar 2017 16:46:56 +0000 (12:46 -0400)
In trace_format() when processing lenstr, if p is NULL and len is 0,
skip the call to buf_add_printable_len() as Coverity considers it an
unconditional dereference of p.

[ghudson@mit.edu: added explanation to commit message]

src/lib/krb5/os/trace.c

index 83c8d4db876a75ac1d940fe5f973635518d5933c..1f9be80f3df047875e80cf45bc515f74093c190b 100644 (file)
@@ -173,7 +173,7 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
             p = va_arg(ap, const char *);
             if (p == NULL && len != 0)
                 k5_buf_add(&buf, "(null)");
-            else
+            else if (p != NULL)
                 buf_add_printable_len(&buf, p, len);
         } else if (strcmp(tmpbuf, "hexlenstr") == 0) {
             len = va_arg(ap, size_t);