From d1f46a5bae81083eb4d20a65b677c8159dadb2a2 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Tue, 31 Mar 2009 21:03:50 +0000 Subject: Fixed memory leaks which would occur if the second of two memory allocations fails. looks right deraadt, krw ok henning --- sbin/ipsecctl/parse.y | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sbin/ipsecctl/parse.y') diff --git a/sbin/ipsecctl/parse.y b/sbin/ipsecctl/parse.y index 7e9f609b9db..5fa6ed91775 100644 --- a/sbin/ipsecctl/parse.y +++ b/sbin/ipsecctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.144 2009/01/30 14:24:52 bluhm Exp $ */ +/* $OpenBSD: parse.y,v 1.145 2009/03/31 21:03:48 tobias Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -1243,11 +1243,15 @@ pushfile(const char *name, int secret) { struct file *nfile; - if ((nfile = calloc(1, sizeof(struct file))) == NULL || - (nfile->name = strdup(name)) == NULL) { + if ((nfile = calloc(1, sizeof(struct file))) == NULL) { warn("malloc"); return (NULL); } + if ((nfile->name = strdup(name)) == NULL) { + warn("malloc"); + free(nfile); + return (NULL); + } if (TAILQ_FIRST(&files) == NULL && strcmp(nfile->name, "-") == 0) { nfile->stream = stdin; free(nfile->name); -- cgit v1.2.3