MDEV-22387: Static_binary_string::q_append() invokes memcpy on NULL
Invoking memcpy() on a NULL pointer is undefined behaviour (even if the length is 0) and gives the compiler permission to assume that the pointer is nonnull. Recent versions of GCC (starting with version 8) are more aggressively optimizing away checks for NULL pointers. This undefined behaviour would cause a SIGSEGV in the test main.func_encrypt on an optimized debug build on GCC 10.2.0.
This commit is contained in:
parent
199863d72b
commit
cb253b8687
@ -313,7 +313,8 @@ public:
|
||||
}
|
||||
void q_append(const char *data, size_t data_len)
|
||||
{
|
||||
memcpy(Ptr + str_length, data, data_len);
|
||||
if (data_len)
|
||||
memcpy(Ptr + str_length, data, data_len);
|
||||
DBUG_ASSERT(str_length <= UINT_MAX32 - data_len);
|
||||
str_length += (uint)data_len;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user