From 54a9d9a38a6fd9c4ee7c508a168c1f78391644cb Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 27 Apr 2016 00:43:30 +0200 Subject: Fix possible memory in zstr on failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/zstr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/zstr.c') diff --git a/src/zstr.c b/src/zstr.c index 308c7ef..6a577b9 100644 --- a/src/zstr.c +++ b/src/zstr.c @@ -81,7 +81,7 @@ zstr(z_t a, char *b, size_t n) n = zstr_length(a, 10); } - if (unlikely(!b) && unlikely(!(b = malloc(n + 1)))) + if (unlikely(!b) && unlikely(!(b = libzahl_temp_allocation = malloc(n + 1)))) libzahl_memfailure(); neg = znegative(a); @@ -111,5 +111,6 @@ zstr(z_t a, char *b, size_t n) } } + libzahl_temp_allocation = 0; return b - neg; } -- cgit v1.2.3-70-g09d2