summaryrefslogtreecommitdiffstats
path: root/usr.sbin/kvm_mkdb/nlist.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2003-09-25 16:52:11 +0000
committerderaadt <deraadt@openbsd.org>2003-09-25 16:52:11 +0000
commit1479d4c6c686560cce3e10c42b0c00c12c339332 (patch)
tree8d1b99d3bb871e1620a6ec07f1d56ce8fd843ed6 /usr.sbin/kvm_mkdb/nlist.c
parenthifn 7956 support (diff)
downloadwireguard-openbsd-1479d4c6c686560cce3e10c42b0c00c12c339332.tar.xz
wireguard-openbsd-1479d4c6c686560cce3e10c42b0c00c12c339332.zip
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");