diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-09-23 12:47:49 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-09-23 12:47:49 +0300 |
commit | 7c5519c12d46ead947d341cbdcbb6fbbe4d4fe1b (patch) | |
tree | 005b12e21b8c38e7bac3aca5042f1145e28acc30 /sql/sql_string.cc | |
parent | 70960bd33d2699bc96821ec0a0381ca6de86e93e (diff) | |
download | mariadb-git-7c5519c12d46ead947d341cbdcbb6fbbe4d4fe1b.tar.gz |
MDEV-22387: Do not violate __attribute__((nonnull))
Passing a null pointer to a nonnull argument is not only undefined
behaviour, but it also grants the compiler the permission to optimize
away further checks whether the pointer is null. GCC -O2 at least
starting with version 8 may do that, potentially causing SIGSEGV.
Diffstat (limited to 'sql/sql_string.cc')
-rw-r--r-- | sql/sql_string.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 177d2a77d09..b79ca82698b 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -826,7 +826,7 @@ int sortcmp(const String *s,const String *t, CHARSET_INFO *cs) int stringcmp(const String *s,const String *t) { uint32 s_len=s->length(),t_len=t->length(),len=MY_MIN(s_len,t_len); - int cmp= memcmp(s->ptr(), t->ptr(), len); + int cmp= len ? memcmp(s->ptr(), t->ptr(), len) : 0; return (cmp) ? cmp : (int) (s_len - t_len); } |