diff --git a/ed.c b/ed.c index 29f4b92..a434625 100644 --- a/ed.c +++ b/ed.c @@ -192,8 +192,10 @@ makeline(char *s, int *off) char c, *begin = s; if (lastidx >= idxsize) { - if (idxsize > SIZE_MAX - NUMLINES || - !(lp = realloc(zero, (idxsize + NUMLINES) * sizeof(*lp)))) + lp = NULL; + if (idxsize <= SIZE_MAX - NUMLINES) + lp = realloc(zero, (idxsize + NUMLINES) * sizeof(*lp)); + if (!lp) error("out of memory"); idxsize += NUMLINES; zero = lp;