summaryrefslogtreecommitdiff
path: root/usr.sbin/kvm_mkdb/nlist.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-25 16:52:12 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-25 16:52:12 +0000
commit5a06d2d49fb4f5b3fb835ae1fd1040ad1c6ac63a (patch)
tree795d27e6b32a197d6e5f59b6020b5cb6b258f9a9 /usr.sbin/kvm_mkdb/nlist.c
parent619288226b2712f74765e6d3386ba50457128048 (diff)
realloc fixes; markus ok
Diffstat (limited to 'usr.sbin/kvm_mkdb/nlist.c')
-rw-r--r--usr.sbin/kvm_mkdb/nlist.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c
index cf4b80c4c74..7f76aec3299 100644
--- a/usr.sbin/kvm_mkdb/nlist.c
+++ b/usr.sbin/kvm_mkdb/nlist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nlist.c,v 1.34 2003/06/26 21:36:39 deraadt Exp $ */
+/* $OpenBSD: nlist.c,v 1.35 2003/09/25 16:52:11 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -33,7 +33,7 @@
#if 0
static char sccsid[] = "from: @(#)nlist.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: nlist.c,v 1.34 2003/06/26 21:36:39 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: nlist.c,v 1.35 2003/09/25 16:52:11 deraadt Exp $";
#endif
#endif /* not lint */
@@ -165,8 +165,18 @@ __aout_knlist(int fd, DB *db, int ksyms)
if (*p != '_') {
len = strlen(p) + 1;
if (len >= snamesize) {
- snamesize = len + 1024;
- sname = realloc(sname, snamesize);
+ char *newsname;
+ int newsnamesize = len + 1024;
+
+ newsname = realloc(sname, newsnamesize);
+ if (newsname == NULL) {
+ if (sname)
+ free(sname);
+ sname = NULL;
+ } else {
+ sname = newsname;
+ snamesize = newsnamesize;
+ }
}
if (sname == NULL)
errx(1, "cannot allocate memory");
@@ -594,8 +604,18 @@ __ecoff_knlist(int fd, DB *db, int ksyms)
/* Need to prepend a '_' */
len = strlen(&mappedfile[extstroff + esyms[i].es_strindex]) + 1;
if (len >= snamesize) {
- snamesize = len + 1024;
- sname = realloc(sname, snamesize);
+ char *newsname;
+ int newsnamesize = len + 1024;
+
+ newsname = realloc(sname, newsnamesize);
+ if (newsname == NULL) {
+ if (sname)
+ free(sname);
+ sname = NULL;
+ } else {
+ sname = newsname;
+ snamesize = newsnamesize;
+ }
}
if (sname == NULL)
errx(1, "cannot allocate memory");