summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-11-15 04:32:32 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-11-15 04:32:32 +0000
commit280291f89a030c541475c7df1c3d76dd43b687a4 (patch)
tree953a260c7278215b3ad17a69f435cc16cc7a353d /usr.bin
parentbbf3c4868bb229cb82f93128598981a135c2d7d7 (diff)
do not leak a lot of memory if a small memory allocation fails, found by
parfait ok kettenis guenther
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/vi/ex/ex_args.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/vi/ex/ex_args.c b/usr.bin/vi/ex/ex_args.c
index ca4c6f2aea7..feec8bea50a 100644
--- a/usr.bin/vi/ex/ex_args.c
+++ b/usr.bin/vi/ex/ex_args.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_args.c,v 1.8 2009/11/14 17:44:53 jsg Exp $ */
+/* $OpenBSD: ex_args.c,v 1.9 2009/11/15 04:32:31 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -318,8 +318,12 @@ ex_buildargv(sp, cmdp, name)
} else
for (argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv)
if ((*ap =
- v_strdup(sp, argv[0]->bp, argv[0]->len)) == NULL)
+ v_strdup(sp, argv[0]->bp, argv[0]->len)) == NULL) {
+ while (--ap >= s_argv)
+ free(*ap);
+ free(s_argv);
return (NULL);
+ }
*ap = NULL;
return (s_argv);
}