diff options
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/array.c | 5 | ||||
-rw-r--r-- | mysys/my_alloc.c | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/mysys/array.c b/mysys/array.c index 07abc460de7..e8b253a9e99 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -138,8 +138,9 @@ void *alloc_dynamic(DYNAMIC_ARRAY *array) array->size_of_element, MYF(array->malloc_flags | MY_WME)))) DBUG_RETURN(0); - memcpy(new_ptr, array->buffer, - array->elements * array->size_of_element); + if (array->elements) + memcpy(new_ptr, array->buffer, + array->elements * array->size_of_element); array->malloc_flags&= ~MY_INIT_BUFFER_USED; } else if (!(new_ptr=(char*) diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 0263283221b..a7d4ec1c248 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -491,7 +491,7 @@ char *strmake_root(MEM_ROOT *root, const char *str, size_t len) void *memdup_root(MEM_ROOT *root, const void *str, size_t len) { char *pos; - if ((pos=alloc_root(root,len))) + if ((pos=alloc_root(root,len)) && len) memcpy(pos,str,len); return pos; } |