summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/mem.c5
-rw-r--r--Src/zsh_system.h4
2 files changed, 8 insertions, 1 deletions
diff --git a/Src/mem.c b/Src/mem.c
index a8f0c37ce..7e0667a33 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -950,7 +950,10 @@ zrealloc(void *ptr, size_t size)
ptr = NULL;
} else {
/* If ptr is NULL, then behave like malloc */
- ptr = malloc(size);
+ if (!(ptr = (void *) malloc(size))) {
+ zerr("fatal error: out of memory");
+ exit(1);
+ }
}
unqueue_signals();
diff --git a/Src/zsh_system.h b/Src/zsh_system.h
index 601de69f6..811340d42 100644
--- a/Src/zsh_system.h
+++ b/Src/zsh_system.h
@@ -286,11 +286,15 @@ struct timezone {
# include <limits.h>
#endif
+#ifdef USE_STACK_ALLOCATION
#ifdef HAVE_VARIABLE_LENGTH_ARRAYS
# define VARARR(X,Y,Z) X (Y)[Z]
#else
# define VARARR(X,Y,Z) X *(Y) = (X *) alloca(sizeof(X) * (Z))
#endif
+#else
+# define VARARR(X,Y,Z) X *(Y) = (X *) zhalloc(sizeof(X) * (Z))
+#endif
/* we should handle unlimited sizes from pathconf(_PC_PATH_MAX) */
/* but this is too much trouble */