From 8036d0a3590dddf4d51ba02bc74ba3a5a96674f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 2 Nov 2020 14:19:21 +0200 Subject: MDEV-22387: Do not violate __attribute__((nonnull)) This follows up commit commit 94a520ddbe39ae97de1135d98699cf2674e6b77e and commit 7c5519c12d46ead947d341cbdcbb6fbbe4d4fe1b. After these changes, the default test suites on a cmake -DWITH_UBSAN=ON build no longer fail due to passing null pointers as parameters that are declared to never be null, but plenty of other runtime errors remain. --- storage/myisam/mi_key.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'storage/myisam') diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 9247fae9e3c..1298232b5fa 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -144,8 +144,11 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); - key+= char_length; + if (char_length) + { + memcpy(key, pos, char_length); + key+= char_length; + } continue; } else if (keyseg->flag & HA_SWAP_KEY) -- cgit v1.2.1