summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-11-02 14:19:21 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-11-02 14:19:21 +0200
commit8036d0a3590dddf4d51ba02bc74ba3a5a96674f7 (patch)
tree13fc7d26725fc5fd58a058b5d8563afef0835ae3 /sql/sql_select.cc
parentd2fab686670fcc6d23930298e4256734dfdbc413 (diff)
downloadmariadb-git-8036d0a3590dddf4d51ba02bc74ba3a5a96674f7.tar.gz
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.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 3b090093060..d1076a54f1b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -26064,10 +26064,10 @@ JOIN::reoptimize(Item *added_where, table_map join_tables,
if (save_to)
{
DBUG_ASSERT(!keyuse.elements);
- memcpy(keyuse.buffer,
- save_to->keyuse.buffer,
- (size_t) save_to->keyuse.elements * keyuse.size_of_element);
keyuse.elements= save_to->keyuse.elements;
+ if (size_t e= keyuse.elements)
+ memcpy(keyuse.buffer,
+ save_to->keyuse.buffer, e * keyuse.size_of_element);
}
/* Add the new access methods to the keyuse array. */