diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2009-03-31 21:03:50 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2009-03-31 21:03:50 +0000 |
commit | d1f46a5bae81083eb4d20a65b677c8159dadb2a2 (patch) | |
tree | ed98e68c11b6221bd5077066cf218fd07f6cce05 /usr.sbin/ospf6d | |
parent | 9b03618dbfb1bc94a0cd3d53ea0e26dc12a627c7 (diff) |
Fixed memory leaks which would occur if the second of two memory
allocations fails.
looks right deraadt, krw
ok henning
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r-- | usr.sbin/ospf6d/parse.y | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/ospf6d/parse.y b/usr.sbin/ospf6d/parse.y index 8d92c092a8d..5d3ac8592db 100644 --- a/usr.sbin/ospf6d/parse.y +++ b/usr.sbin/ospf6d/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.15 2009/01/26 23:20:57 stsp Exp $ */ +/* $OpenBSD: parse.y,v 1.16 2009/03/31 21:03:49 tobias Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -825,11 +825,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) { log_warn("malloc"); return (NULL); } + if ((nfile->name = strdup(name)) == NULL) { + log_warn("malloc"); + free(nfile); + return (NULL); + } if ((nfile->stream = fopen(nfile->name, "r")) == NULL) { log_warn("%s", nfile->name); free(nfile->name); |