summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2024-01-18 22:26:42 +0000
committerLaurent Bercot <ska@appnovation.com>2024-01-18 22:26:42 +0000
commit83bcd1e5ed5eb5c4abc5154dae4dc6e133c8ddb4 (patch)
treecbaf255dd258eb7429f2f40a2f3b82981e97f1ba /src/libstddjb
parentcb8cab7b0304b72393ea3a8db755077b1286a686 (diff)
downloadskalibs-83bcd1e5ed5eb5c4abc5154dae4dc6e133c8ddb4.tar.xz
Do not free on failure to reallocate to size 0 (lol.)
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/alloc_realloc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstddjb/alloc_realloc.c b/src/libstddjb/alloc_realloc.c
index 82be92b..6d5c680 100644
--- 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 ;
}