summaryrefslogtreecommitdiff
path: root/Src/mem.c
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2018-04-07 15:12:57 +0200
committerAxel Beckert <abe@deuxchevaux.org>2018-04-07 15:12:57 +0200
commit6e1ab9aa550695ee7e3d467b4173c0b83ba7f759 (patch)
tree8fb7faa4364a7cbf1cba48296a5f537e13f2a8d9 /Src/mem.c
parent5ad56a41f1ee2e61abca079f5ea8909f895ac2dd (diff)
parentf027f1d6e876708bc75d4217e1ca26898658d8d3 (diff)
downloadzsh-6e1ab9aa550695ee7e3d467b4173c0b83ba7f759.tar.gz
zsh-6e1ab9aa550695ee7e3d467b4173c0b83ba7f759.zip
Merge tag 'zsh-5.4.2-test-2' / 'upstream' branch into 'debian' branch
Test version 2 prior to zsh 5.5.
Diffstat (limited to 'Src/mem.c')
-rw-r--r--Src/mem.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Src/mem.c b/Src/mem.c
index 840bbb6e4..77e4375f0 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -1719,7 +1719,13 @@ calloc(MALLOC_ARG_T n, MALLOC_ARG_T size)
if (!(l = n * size))
return (MALLOC_RET_T) m_high;
- r = malloc(l);
+ /*
+ * use realloc() (with a NULL `p` argument it behaves exactly the same
+ * as malloc() does) to prevent an infinite loop caused by sibling-call
+ * optimizations (the malloc() call would otherwise be replaced by an
+ * unconditional branch back to line 1719 ad infinitum).
+ */
+ r = realloc(NULL, l);
memset(r, 0, l);
@@ -1879,16 +1885,14 @@ bin_mem(char *name, char **argv, Options ops, int func)
mod_export void
zfree(void *p, UNUSED(int sz))
{
- if (p)
- free(p);
+ free(p);
}
/**/
mod_export void
zsfree(char *p)
{
- if (p)
- free(p);
+ free(p);
}
/**/