summaryrefslogtreecommitdiff
path: root/cad/spice/patches/patch-an
blob: 276b95f52f0dd066563aa1bd4a1dcd9ad1ecf484 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$NetBSD: patch-an,v 1.1 1999/10/01 17:05:16 dmcmahill Exp $

--- src/lib/fte//dimens.c.orig	Sun Apr 25 18:03:19 1993
+++ src/lib/fte//dimens.c	Thu Sep 30 10:02:10 1999
@@ -21,9 +21,21 @@
 {
     int i;
-    char buf[BSIZE_SP];
+    char *buf;
+    if ( (buf = (char *) malloc(BSIZE_SP*sizeof(char))) == NULL)
+    {
+      fprintf(stderr,"lib:fte:dimns:dimstring:  malloc failed\n");
+      exit(1);
+    }
 
     if (!data || length < 1)
 	return NULL;
 
+    if (length > BSIZE_SP)
+    {
+      fprintf(stderr,"WARNING, lib:fte:dimns:dimstring: length=%d > BSIZE_SP=%d\n",
+	length,BSIZE_SP);
+      length = BSIZE_SP;
+    }
+
     buf[0] = '\0';
     for (i=0; i < length; i++) {
@@ -31,5 +43,5 @@
 	    (i < length - 1) ? "," : "");
     }
-    /* XXX Should I return a copy instead? */
+    
     return(buf);
 }
@@ -44,8 +56,21 @@
 {
     int i;
-    char buf[BSIZE_SP];
+    char *buf;          
+
+    if ( (buf = (char *) malloc(BSIZE_SP*sizeof(char))) == NULL)
+    {
+      fprintf(stderr,"lib:fte:dimns:indexstring:  malloc failed\n");
+      exit(1);
+    }
 
     if (!data || length < 1)
 	return NULL;
+
+    if (length > BSIZE_SP)
+    {
+      fprintf(stderr,"WARNING, lib:fte:dimns:indexstring: length=%d > BSIZE_SP=%d\n",
+        length,BSIZE_SP);
+      length = BSIZE_SP;
+    }
 
     buf[0] = '\0';