Module Name:    src
Committed By:   rillig
Date:           Sun Mar 14 16:03:04 UTC 2021

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make: return failure in TryParseIntBase0 for empty string

No functional change since the only caller of TryParseIntBase0 already
handles all possible parse errors.  Without this check, the code just
looked wrong though.


To generate a diff of this commit:
cvs rdiff -u -r1.864 -r1.865 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.864 src/usr.bin/make/var.c:1.865
--- src/usr.bin/make/var.c:1.864	Sun Mar 14 15:43:31 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 16:03:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.865 2021/03/14 16:03:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.865 2021/03/14 16:03:04 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2308,6 +2308,9 @@ TryParseIntBase0(const char **pp, int *o
 
 	errno = 0;
 	n = strtol(*pp, &end, 0);
+
+	if (end == *pp)
+		return FALSE;
 	if ((n == LONG_MIN || n == LONG_MAX) && errno == ERANGE)
 		return FALSE;
 	if (n < INT_MIN || n > INT_MAX)

Reply via email to