From 8036d0a3590dddf4d51ba02bc74ba3a5a96674f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 2 Nov 2020 14:19:21 +0200 Subject: 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. --- sql/sql_string.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sql/sql_string.cc') diff --git a/sql/sql_string.cc b/sql/sql_string.cc index b79ca82698b..4e0c7aea84b 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2016, MariaDB + Copyright (c) 2016, 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 @@ -175,8 +175,8 @@ bool String::copy(const String &str) { if (alloc(str.str_length)) return TRUE; - str_length=str.str_length; - bmove(Ptr,str.Ptr,str_length); // May be overlapping + if ((str_length=str.str_length)) + bmove(Ptr,str.Ptr,str_length); // May be overlapping Ptr[str_length]=0; str_charset=str.str_charset; return FALSE; @@ -539,8 +539,11 @@ bool String::append_ulonglong(ulonglong val) bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs) { + if (!arg_length) + return false; + uint32 offset; - + if (needs_conversion(arg_length, cs, str_charset, &offset)) { uint32 add_length; -- cgit v1.2.1