From 6af6f3eb9beb30d6a50551e09515e88fdbd02ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 3 Feb 2023 16:21:17 +0100 Subject: [PATCH] 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 --- glib/gslice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gslice.c b/glib/gslice.c index 11d8c3fb2..63a048458 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -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));