summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2020-03-29 00:41:57 +0300
committerEugene Kosov <claprix@yandex.ru>2020-03-31 00:44:01 +0300
commit5001487632d60c2d0d9ce5c1be697c016813a994 (patch)
treed1abdaea4197535fbe02d376d2d5d3e119e9c7f8 /mysys
parentedd7e7c85d301c7f8c4ecc1f38dcb1151a11b792 (diff)
downloadmariadb-git-5001487632d60c2d0d9ce5c1be697c016813a994.tar.gz
MDEV-22074 UBSAN: applying zero offset to null pointer in hash.c
The fix: return fast when no work should be performed.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/hash.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/mysys/hash.c b/mysys/hash.c
index 2c45ac35710..1270d14c1f6 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -116,17 +116,23 @@ my_hash_init2(HASH *hash, uint growth_size, CHARSET_INFO *charset,
static inline void my_hash_free_elements(HASH *hash)
{
uint records= hash->records;
+ if (records == 0)
+ return;
+
/*
Set records to 0 early to guard against anyone looking at the structure
during the free process
*/
hash->records= 0;
+
if (hash->free)
{
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
HASH_LINK *end= data + records;
- while (data < end)
+ do
+ {
(*hash->free)((data++)->data);
+ } while (data < end);
}
}