summaryrefslogtreecommitdiff
path: root/usr.sbin/lpr/common_source
diff options
context:
space:
mode:
authorPeter Valchev <pvalchev@cvs.openbsd.org>2003-09-26 06:01:43 +0000
committerPeter Valchev <pvalchev@cvs.openbsd.org>2003-09-26 06:01:43 +0000
commit35ad2f35226d93d8529515f531dee25d01a17280 (patch)
tree559da7af7e7804fcfa094ff55044cdd4fcc196a3 /usr.sbin/lpr/common_source
parentb271c2cc29581f93e70d10ce2b71d94b6fb660c8 (diff)
realloc fixes; ok deraadt millert
Diffstat (limited to 'usr.sbin/lpr/common_source')
-rw-r--r--usr.sbin/lpr/common_source/common.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index ac3527e4184..8f6ff38f778 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.25 2003/06/02 23:36:53 millert Exp $ */
+/* $OpenBSD: common.c,v 1.26 2003/09/26 06:01:41 pvalchev Exp $ */
/* $NetBSD: common.c,v 1.21 2000/08/09 14:28:50 itojun Exp $ */
/*
@@ -39,7 +39,7 @@
#if 0
static const char sccsid[] = "@(#)common.c 8.5 (Berkeley) 4/28/95";
#else
-static const char rcsid[] = "$OpenBSD: common.c,v 1.25 2003/06/02 23:36:53 millert Exp $";
+static const char rcsid[] = "$OpenBSD: common.c,v 1.26 2003/09/26 06:01:41 pvalchev Exp $";
#endif
#endif /* not lint */
@@ -281,11 +281,17 @@ getq(struct queue ***namelist)
* realloc the maximum size.
*/
if (++nitems > arraysz) {
- arraysz *= 2;
- queue = (struct queue **)realloc(queue,
- arraysz * sizeof(struct queue *));
- if (queue == NULL)
+ struct queue **newqueue;
+ size_t newarraysz = arraysz * 2;
+ newqueue = (struct queue **)realloc(queue,
+ newarraysz * sizeof(struct queue *));
+ if (newqueue == NULL) {
+ free(queue);
+ queue = NULL;
goto errdone;
+ }
+ queue = newqueue;
+ arraysz = newarraysz;
}
queue[nitems-1] = q;
}