summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-11-02 15:48:47 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-11-02 15:48:47 +0200
commitc7f322c91faf97a9f758c288b38e1385fd89b32d (patch)
treecf2a4cf562acffdf5b4b96d84e34f29c7f428458 /mysys
parentd5ce7824444b7491f420061076ae5087d4829428 (diff)
parent8036d0a3590dddf4d51ba02bc74ba3a5a96674f7 (diff)
downloadmariadb-git-c7f322c91faf97a9f758c288b38e1385fd89b32d.tar.gz
Merge 10.2 into 10.3
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 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;
}