Skip to content
Permalink
Browse files
MDEV-21362: Do not call memcmp on null pointers
Starting with commit 3734439
we would invoke memcmp() unconditionally, even if the length is zero.
But, a call to memcmp() is undefined if any parameter is a null pointer,
even if the length is zero.

In the following tests, a null pointer is being passed to the comparison:
vcol.vcol_keys_innodb gcol.gcol_keys_innodb main.func_group_innodb
innodb.innodb_bug53592

cmp_data(): Keep WITH_UBSAN happy and avoid potential future bugs
in optimized builds, like the one addressed by
commit fc168c3 (MDEV-15587).
  • Loading branch information
dr-m committed Jan 29, 2020
1 parent 50324ce commit c69a862
Showing 1 changed file with 1 addition and 2 deletions.
@@ -448,8 +448,7 @@ cmp_data(
}

ulint len = std::min(len1, len2);

int cmp = memcmp(data1, data2, len);
int cmp = len ? memcmp(data1, data2, len) : 0;

if (cmp) {
return (cmp);

0 comments on commit c69a862

Please sign in to comment.