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/item_sum.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/item_sum.cc')
-rw-r--r-- | sql/item_sum.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index e50822e71f2..9490c71c19e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2015, MariaDB + Copyright (c) 2008, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -464,7 +464,8 @@ Item_sum::Item_sum(THD *thd, Item_sum *item): if (!(orig_args= (Item**) thd->alloc(sizeof(Item*)*arg_count))) return; } - memcpy(orig_args, item->orig_args, sizeof(Item*)*arg_count); + if (arg_count) + memcpy(orig_args, item->orig_args, sizeof(Item*)*arg_count); init_aggregator(); with_distinct= item->with_distinct; if (item->aggr) @@ -1136,7 +1137,8 @@ Item_sum_num::fix_fields(THD *thd, Item **ref) check_sum_func(thd, ref)) return TRUE; - memcpy (orig_args, args, sizeof (Item *) * arg_count); + if (arg_count) + memcpy (orig_args, args, sizeof (Item *) * arg_count); fixed= 1; return FALSE; } @@ -3312,7 +3314,8 @@ Item_func_group_concat(THD *thd, Name_resolution_context *context_arg, /* orig_args is only used for print() */ orig_args= (Item**) (order + arg_count_order); - memcpy(orig_args, args, sizeof(Item*) * arg_count); + if (arg_count) + memcpy(orig_args, args, sizeof(Item*) * arg_count); } |