Fix virRealloc bug for zero-size

This commit is contained in:
Daniel P. Berrange 2008-10-10 18:17:13 +00:00
parent 7e0d3e62e9
commit 0c4a048485
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Fri Oct 10 19:16:00 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/memory.c: If size*count== 0, then virRelloc must not
return a failure, it is same as virFree.
Fri Oct 10 17:51:00 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* docs/libvirt.rng: Document SDL attributes in schema

View File

@ -158,7 +158,7 @@ int __virReallocN(void *ptrptr, size_t size, size_t count)
return -1;
}
tmp = realloc(*(void**)ptrptr, size * count);
if (!tmp)
if (!tmp && (size * count))
return -1;
*(void**)ptrptr = tmp;
return 0;