scc

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

commit 2b8586296aa24f827684ab8e79a271530e56c323
parent 3fdc234cabe3103af7b43e3459a5e2c14260d545
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); }