sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit f45156d5b4f49ada1c130168a2aabdcb02f430a4
parent 18f6c5e0142d09ed1c104b7dad96d17ce89820d4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  6 Mar 2018 14:38:23 +0100

Simplify expression in makeline()

This expression was wrong, but it was causing a false positive
in some compilers that couldn't see that error() cannot return.
The actual problem of the line is that it was too complex and it is better
to split it in simplex expressions.

Diffstat:
Med.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 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;