diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-04-27 00:43:30 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-04-27 00:43:30 +0200 |
| commit | 54a9d9a38a6fd9c4ee7c508a168c1f78391644cb (patch) | |
| tree | 391c61cc6537a90bf29bca0a9cde31de014db546 /src/zstr.c | |
| parent | zstr: add new parameter, n: the known limit out the length of the output (diff) | |
| download | libzahl-54a9d9a38a6fd9c4ee7c508a168c1f78391644cb.tar.gz libzahl-54a9d9a38a6fd9c4ee7c508a168c1f78391644cb.tar.bz2 libzahl-54a9d9a38a6fd9c4ee7c508a168c1f78391644cb.tar.xz | |
Fix possible memory in zstr on failure
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
| -rw-r--r-- | src/zstr.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; } |
