7da5ddc215
with SunPro.
41 lines
1.2 KiB
Text
41 lines
1.2 KiB
Text
$NetBSD: patch-bm,v 1.1 2006/01/18 23:24:12 rillig Exp $
|
|
|
|
Don't use alloca. (Solaris would require <alloca.h> to be included for
|
|
it.)
|
|
|
|
--- src/utils.c.orig 2003-09-10 20:52:09.000000000 +0200
|
|
+++ src/utils.c 2006-01-16 14:44:06.890343700 +0100
|
|
@@ -19,6 +19,7 @@ Boston, MA 02111-1307, USA. */
|
|
#include <ctype.h>
|
|
#include <signal.h>
|
|
#include <stdio.h>
|
|
+#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
@@ -328,16 +329,23 @@ const char *name_with_loc(region r, cons
|
|
char *index;
|
|
int base_len;
|
|
char *base_name;
|
|
+ char *result;
|
|
|
|
if ((index = strstr(name, "@")))
|
|
base_len = index - name;
|
|
else
|
|
base_len = strlen(name);
|
|
- base_name = alloca((base_len + 2) * sizeof(char));
|
|
+ base_name = malloc((base_len + 2) * sizeof(char));
|
|
+ if (base_name == NULL) {
|
|
+ perror("cqual: in name_with_loc");
|
|
+ exit(EXIT_FAILURE);
|
|
+ }
|
|
strncpy(base_name, name, base_len);
|
|
base_name[base_len] = '@';
|
|
base_name[base_len+1] = '\0';
|
|
- return rstrcat(r, base_name, inttostr(r, loc->lineno));
|
|
+ result = rstrcat(r, base_name, inttostr(r, loc->lineno));
|
|
+ free(base_name);
|
|
+ return result;
|
|
}
|
|
|
|
/* A function to let you pass a function pointer which prints to
|