mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-05 06:50:21 +02:00
Do not pass null for free, memcpy and memmove
* lib/jit_memory.c: Do not call free on NULL pointers. * include/lightning/jit_private.h, lib/jit_note.c, lib/lightning.c: Add a wrapper to memcpy and memmove to not actually call those functions with a zero size argument, and likely also a null src or dst.
This commit is contained in:
parent
a8c180a926
commit
0d9ac79a12
6 changed files with 52 additions and 19 deletions
|
@ -38,6 +38,22 @@ static jit_free_func_ptr jit_free_ptr = jit_default_free_func;
|
|||
/*
|
||||
* Implementation
|
||||
*/
|
||||
jit_pointer_t
|
||||
jit_memcpy(jit_pointer_t dst, jit_pointer_t src, jit_word_t size)
|
||||
{
|
||||
if (size)
|
||||
return (memcpy(dst, src, size));
|
||||
return (dst);
|
||||
}
|
||||
|
||||
jit_pointer_t
|
||||
jit_memmove(jit_pointer_t dst, jit_pointer_t src , jit_word_t size)
|
||||
{
|
||||
if (size)
|
||||
return (memmove(dst, src, size));
|
||||
return (dst);
|
||||
}
|
||||
|
||||
void
|
||||
jit_set_memory_functions(jit_alloc_func_ptr alloc_ptr,
|
||||
jit_realloc_func_ptr realloc_ptr,
|
||||
|
@ -82,8 +98,10 @@ jit_realloc(jit_pointer_t *ptr, jit_word_t old_size, jit_word_t new_size)
|
|||
void
|
||||
jit_free(jit_pointer_t *ptr)
|
||||
{
|
||||
(*jit_free_ptr)(*ptr);
|
||||
*ptr = NULL;
|
||||
if (*ptr) {
|
||||
(*jit_free_ptr)(*ptr);
|
||||
*ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue