summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index a9065816cf..1e64db38fc 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -942,6 +942,9 @@ BOOL yesno(char *p)
void *malloc_(size_t size)
{
+ if (size == 0) {
+ return NULL;
+ }
#undef malloc
return malloc(size);
#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY
@@ -953,6 +956,9 @@ void *malloc_(size_t size)
static void *calloc_(size_t count, size_t size)
{
+ if (size == 0 || count == 0) {
+ return NULL;
+ }
#undef calloc
return calloc(count, size);
#define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY
@@ -981,6 +987,9 @@ void *malloc_array(size_t el_size, unsigned int count)
return NULL;
}
+ if (el_size == 0 || count == 0) {
+ return NULL;
+ }
#if defined(PARANOID_MALLOC_CHECKER)
return malloc_(el_size*count);
#else
@@ -1010,6 +1019,9 @@ void *calloc_array(size_t size, size_t nmemb)
if (nmemb >= MAX_ALLOC_SIZE/size) {
return NULL;
}
+ if (size == 0 || nmemb == 0) {
+ return NULL;
+ }
#if defined(PARANOID_MALLOC_CHECKER)
return calloc_(nmemb, size);
#else