summaryrefslogtreecommitdiff
path: root/plugin
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 /plugin
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 'plugin')
-rw-r--r--plugin/server_audit/server_audit.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index a029b426ea1..a4884f17c75 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -706,6 +706,8 @@ static char *coll_search(struct user_coll *c, const char *n, size_t len)
{
struct user_name un;
struct user_name *found;
+ if (!c->n_users)
+ return 0;
un.name_len= len;
un.name= (char *) n;
found= (struct user_name*) bsearch(&un, c->users, c->n_users,
@@ -736,7 +738,8 @@ static int coll_insert(struct user_coll *c, char *n, size_t len)
static void coll_sort(struct user_coll *c)
{
- qsort(c->users, c->n_users, sizeof(c->users[0]), cmp_users);
+ if (c->n_users)
+ qsort(c->users, c->n_users, sizeof(c->users[0]), cmp_users);
}
@@ -967,7 +970,8 @@ static void get_str_n(char *dest, int *dest_len, size_t dest_size,
if (src_len >= dest_size)
src_len= dest_size - 1;
- memcpy(dest, src, src_len);
+ if (src_len)
+ memcpy(dest, src, src_len);
dest[src_len]= 0;
*dest_len= (int)src_len;
}