[hackers] [sbase] Simplify expression in makeline() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 3 Jul 2018 10:33:27 +0200 (CEST)

commit f45156d5b4f49ada1c130168a2aabdcb02f430a4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Mar 6 14:38:23 2018 +0100
Commit: sin <sin_AT_2f30.org>
CommitDate: Tue Jul 3 09:31:46 2018 +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.

diff --git a/ed.c b/ed.c
index 29f4b92..a434625 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -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;
Received on Tue Jul 03 2018 - 10:33:27 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 03 2018 - 10:36:29 CEST