shithub: scc

Download patch

ref: 9e604423d747253990c6b62da8769a9ebbba29a2
parent: da8a8c7392b7176a11fd7eab84d6f9b2d27ae590
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Aug 9 19:52:07 EDT 2019

[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.

--- a/src/cmd/ld/symbol.c
+++ b/src/cmd/ld/symbol.c
@@ -37,8 +37,7 @@
 	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);
 	}