gslice: Do not try to memset-0 NULL a pointer

According to the docs, g_slice_free1() is supposed to do nothing if
@mem_block is NULL, but we still try to zero it in case we're using
g_mem_gc_friendly.

So avoid this case.

Closes: #2908
This commit is contained in:
Marco Trevisan (Treviño) 2023-02-03 16:21:17 +01:00
parent 95cbff0fd2
commit 6af6f3eb9b

View File

@ -331,7 +331,7 @@ void
g_slice_free1 (gsize mem_size,
gpointer mem_block)
{
if (G_UNLIKELY (g_mem_gc_friendly))
if (G_UNLIKELY (g_mem_gc_friendly && mem_block))
memset (mem_block, 0, mem_size);
g_free_sized (mem_block, mem_size);
TRACE (GLIB_SLICE_FREE((void*)mem_block, mem_size));