From 207aae5d0003c6ec73dca23126a894f55de67fcd Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 1 Nov 1995 17:16:33 +0000 Subject: Always ensure space for trailing NULL in argv --- usr.bin/make/str.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index 305ca49acfb..77f773483be 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.10 1995/06/14 15:19:56 christos Exp $ */ +/* $NetBSD: str.c,v 1.10.2.1 1995/10/30 22:55:14 jtc Exp $ */ /*- * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90"; #else -static char rcsid[] = "$NetBSD: str.c,v 1.10 1995/06/14 15:19:56 christos Exp $"; +static char rcsid[] = "$NetBSD: str.c,v 1.10.2.1 1995/10/30 22:55:14 jtc Exp $"; #endif #endif /* not lint */ @@ -60,7 +60,7 @@ void str_init() { char *p1; - argv = (char **)emalloc((argmax = 50) * sizeof(char *)); + argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *)); argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1); } @@ -207,7 +207,7 @@ brk_string(str, store_argc, expand) if (argc == argmax) { argmax *= 2; /* ramp up fast */ if (!(argv = (char **)realloc(argv, - argmax * sizeof(char *)))) + (argmax + 1) * sizeof(char *)))) enomem(); } argv[argc++] = start; -- cgit v1.2.3