summaryrefslogtreecommitdiff
path: root/lib/libkvm/kvm_proc.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-10-22 04:13:36 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-10-22 04:13:36 +0000
commit3560cfcb22e76cdbc385404940d990b7e3c9ae5e (patch)
tree34c57166005cfddda3329c10f185455a72bb52c0 /lib/libkvm/kvm_proc.c
parentf56feb15e1720c64d26d54dca4fc152a720b9b69 (diff)
Don't leak the old data if _kvm_reallocarray() fails
ok millert@ doug@
Diffstat (limited to 'lib/libkvm/kvm_proc.c')
-rw-r--r--lib/libkvm/kvm_proc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index fa1858211d4..70533557de3 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_proc.c,v 1.51 2014/10/15 02:03:05 deraadt Exp $ */
+/* $OpenBSD: kvm_proc.c,v 1.52 2014/10/22 04:13:35 guenther Exp $ */
/* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -281,11 +281,13 @@ kvm_argv(kvm_t *kd, const struct kinfo_proc *p, u_long addr, int narg,
int off;
char **pp;
char *op = kd->argspc;
+ char *newp;
- kd->argspc = _kvm_reallocarray(kd, kd->argspc,
+ newp = _kvm_reallocarray(kd, kd->argspc,
kd->arglen, 2);
- if (kd->argspc == 0)
+ if (newp == 0)
return (0);
+ kd->argspc = newp;
kd->arglen *= 2;
/*
* Adjust argv pointers in case realloc moved