From: Zdenek Kabelac Date: Fri, 26 Feb 2016 09:15:24 +0000 (+0100) Subject: coverity: helping coverity with NULL pointer X-Git-Tag: v2_02_144~3 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=2988fa3c21cf84071446bc11cb61d5b8507c088c;p=lvm2.git coverity: helping coverity with NULL pointer Helping with understanding we will not try to deref NULL pointer, as if the sizes are initialized to NULL it also means 'mem' would be NULL, but thats too hard to model so make it obvious. --- diff --git a/libdaemon/client/config-util.c b/libdaemon/client/config-util.c index 7a7dfed9d..e262182b6 100644 --- a/libdaemon/client/config-util.c +++ b/libdaemon/client/config-util.c @@ -366,9 +366,9 @@ int buffer_append(struct buffer *buf, const char *string) { int len = strlen(string); - if ((buf->allocated - buf->used <= len) && + if ((!buf->mem || (buf->allocated - buf->used <= len)) && !buffer_realloc(buf, len + 1)) - return 0; + return 0; strcpy(buf->mem + buf->used, string); buf->used += len;