Skip to contentSkip to conversation

ASN.1: Fix NULL check after strdup call

PATCH New Denis Efremov 1 participant 1 message Aug 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASN.1: Fix NULL check after strdup call

strdup function returns a pointer to the newly allocated string, or a NULL if an error occurred. Thus, grammar_name should be checked right after strdup call. p variable can't be NULL in this context. This follows from p check before the strdup call.

---
 scripts/asn1_compiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/asn1_compiler.c +1 -1
index adabd4145264..985fb81cae79 100644
@@ -625,7 +625,7 @@ int main(int argc, char **argv)
 	p = strrchr(argv[1], '/');
 	p = p ? p + 1 : argv[1];
 	grammar_name = strdup(p);
-	if (!p) {
+	if (!grammar_name) {
 		perror(NULL);
 		exit(1);
 	}
Signature · 1 line
2.21.0