scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 9e604423d747253990c6b62da8769a9ebbba29a2
parent da8a8c7392b7176a11fd7eab84d6f9b2d27ae590
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  9 Aug 2019 23:52:07 +0100

[ld] Fix comparision in install()

At that point len was ulready used for malloc(), so the code already
was undefined. It is also impossible to have zero in lenght there because
it is the lenght of the name plus one.

Diffstat:
Msrc/cmd/ld/symbol.c | 3+--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/cmd/ld/symbol.c b/src/cmd/ld/symbol.c @@ -37,8 +37,7 @@ install(char *name) h = genhash(name) % NR_SYMBOL; len = strlen(name) + 1; sym = malloc(sizeof(*sym)); - s = malloc(len); - if (!len || !s) { + if ((s = malloc(len)) == NULL) { error("out of memory"); exit(EXIT_FAILURE); }