diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-02 14:19:21 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-02 14:19:21 +0200 |
commit | 8036d0a3590dddf4d51ba02bc74ba3a5a96674f7 (patch) | |
tree | 13fc7d26725fc5fd58a058b5d8563afef0835ae3 /sql/field.cc | |
parent | d2fab686670fcc6d23930298e4256734dfdbc413 (diff) | |
download | mariadb-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/field.cc')
-rw-r--r-- | sql/field.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sql/field.cc b/sql/field.cc index bdaaecc2026..fbce8b9041d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8446,7 +8446,10 @@ int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr, b_length=get_length(b_ptr); if (b_length > max_length) b_length=max_length; - diff=memcmp(a,b,MY_MIN(a_length,b_length)); + if (uint32 len= MY_MIN(a_length,b_length)) + diff= memcmp(a,b,len); + else + diff= 0; return diff ? diff : (int) (a_length - b_length); } @@ -8503,7 +8506,8 @@ uint Field_blob::get_key_image(uchar *buff,uint length, imagetype type_arg) length=(uint) blob_length; } int2store(buff,length); - memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length); + if (length) + memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length); return HA_KEY_BLOB_LENGTH+length; } |