File 0436-erts-Fix-bug-in-debug_free-for-NULL-pointer.patch of Package erlang

From 1801a42d032bf43b1e7bdb54e03ec4617a80fb0d Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Mon, 15 Oct 2018 15:55:13 +0200
Subject: [PATCH] erts: Fix bug in debug_free for NULL pointer

causing ASSERT in sys_memset to fail.
---
 erts/emulator/beam/erl_alloc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c
index 8fe1ccb758..9e36d5e0d1 100644
--- a/erts/emulator/beam/erl_alloc.c
+++ b/erts/emulator/beam/erl_alloc.c
@@ -4030,6 +4030,9 @@ debug_free(ErtsAlcType_t n, void *extra, void *ptr)
 
     ASSERT(ERTS_ALC_N_MIN <= n && n <= ERTS_ALC_N_MAX);
 
+    if (!ptr)
+        return;
+
     dptr = check_memory_fence(ptr, &size, n, ERTS_ALC_O_FREE);
 
 #ifdef ERTS_ALC_A_EXEC
-- 
2.16.4