summaryrefslogtreecommitdiffstats
path: root/Src/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 7ea669f35..2c730b910 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4574,7 +4574,8 @@ char *
gethere(char **strp, int typ)
{
char *buf;
- int bsiz, qt = 0, strip = 0;
+ int qt = 0, strip = 0;
+ size_t bsiz;
char *s, *t, *bptr, c;
char *str = *strp;
@@ -4601,7 +4602,7 @@ gethere(char **strp, int typ)
if (bptr >= buf + bsiz - 2) {
ptrdiff_t toff = t - buf;
ptrdiff_t bptroff = bptr - buf;
- char *newbuf = realloc(buf, 2 * bsiz);
+ char *newbuf = (bsiz <= SIZE_MAX / 2 ) ? realloc(buf, 2 * bsiz) : NULL;
if (!newbuf) {
/* out of memory */
zfree(buf, bsiz);