summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-11-03 19:11:36 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-11-03 19:11:36 +0200
commitc498250888ec126fddda2867d1239b2a7734482f (patch)
treee308174c977c0981d8e36f6f9b791b1b266d0cb0 /mysys
parent09a1f0075a8d5752dd7b2940a20d86a040af1741 (diff)
parent1418439d3823fe059b41092af72ab32d5e7cd7ab (diff)
downloadmariadb-git-c498250888ec126fddda2867d1239b2a7734482f.tar.gz
Diffstat (limited to 'mysys')
-rw-r--r--mysys/array.c5
-rw-r--r--mysys/my_alloc.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/mysys/array.c b/mysys/array.c
index 1d1d9dd1c64..59698a4cc7c 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -140,8 +140,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 d7e62726b22..edcb4ce7483 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -477,7 +477,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;
}