]> sourceware.org Git - lvm2.git/commitdiff
coverity: helping coverity with NULL pointer
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 26 Feb 2016 09:15:24 +0000 (10:15 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 26 Feb 2016 09:21:36 +0000 (10:21 +0100)
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.

libdaemon/client/config-util.c

index 7a7dfed9dbf7780811081ab3d5ac3786d6451748..e262182b6274f2d3e22b5ce6f5f492df514caef5 100644 (file)
@@ -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;
This page took 0.041866 seconds and 5 git commands to generate.