mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 03:47:17 +02:00
MDEV-20917 InnoDB is passing NULL to nonnull function parameters
mem_heap_dup(): Avoid mem_heap_alloc() and memcpy() of data=NULL, len=0.
trx_undo_report_insert_virtual(), trx_undo_page_report_insert(),
trx_undo_page_report_modify(): Avoid memcpy(ptr, NULL, 0).
dfield_data_is_binary_equal(): Correctly handle data=NULL, len=0.
rec_init_offsets_temp(): Do allow def_val=NULL in the interface.
This clean-up was motivated by WITH_UBSAN, and no bug related to this
was observed in the wild. It should be noted that undefined behaviour
such as memcpy(ptr, NULL, 0) could allow compilers to perform unsafe
optimizations, like it was the case in
commit fc168c3a5e (MDEV-15587).
This commit is contained in:
parent
cb14d2e1a5
commit
bef843b97f
6 changed files with 31 additions and 22 deletions
|
|
@ -237,7 +237,10 @@ inline
|
|||
void*
|
||||
mem_heap_dup(mem_heap_t* heap, const void* data, size_t len)
|
||||
{
|
||||
return(memcpy(mem_heap_alloc(heap, len), data, len));
|
||||
ut_ad(data || !len);
|
||||
return UNIV_LIKELY(data != NULL)
|
||||
? memcpy(mem_heap_alloc(heap, len), data, len)
|
||||
: NULL;
|
||||
}
|
||||
|
||||
/** Duplicate a NUL-terminated string, allocated from a memory heap.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue