Fix malloc of 0 size.

This commit is contained in:
Milan Broz
2012-06-18 15:03:47 +02:00
parent 104c7d6c4f
commit e37016bf64

View File

@@ -317,7 +317,7 @@ static int create_empty_header(const char *new_file, const char *old_file,
log_dbg("Creating empty file %s of size %lu.", new_file, (unsigned long)size);
if (!(buf = malloc(size)))
if (!size || !(buf = malloc(size)))
return -ENOMEM;
memset(buf, 0, size);