summaryrefslogtreecommitdiff
path: root/sql/unireg.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/unireg.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/unireg.cc')
-rw-r--r--sql/unireg.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 083960523c1..92949931f77 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -921,8 +921,11 @@ static bool pack_fields(uchar **buff_arg, List<Create_field> &create_fields,
it.rewind();
while ((field=it++))
{
- memcpy(buff, field->comment.str, field->comment.length);
- buff+= field->comment.length;
+ if (size_t l= field->comment.length)
+ {
+ memcpy(buff, field->comment.str, l);
+ buff+= l;
+ }
}
}
*buff_arg= buff;