1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2016-02-26 10:15:24 +01:00
parent 85a593c191
commit 2988fa3c21

View 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;