skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 83bcd1e5ed5eb5c4abc5154dae4dc6e133c8ddb4
parent cb8cab7b0304b72393ea3a8db755077b1286a686
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Thu, 18 Jan 2024 22:26:42 +0000

 Do not free on failure to reallocate to size 0 (lol.)

Signed-off-by: Laurent Bercot <ska@appnovation.com>

Diffstat:
Msrc/libstddjb/alloc_realloc.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/libstddjb/alloc_realloc.c b/src/libstddjb/alloc_realloc.c @@ -5,8 +5,9 @@ int alloc_realloc (char **x, size_t n) { - char *y = n ? (char *)realloc(*x, n) : (free(*x), (char *)alloc(0)) ; + char *y = n ? realloc(*x, n) : alloc(0) ; if (!y) return 0 ; + if (!n) free(*x) ; *x = y ; return 1 ; }