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 /bin | |
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 'bin')
-rw-r--r-- | bin/chio/parse.y | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/chio/parse.y b/bin/chio/parse.y index 0c5a32c9978..4f232c7a663 100644 --- a/bin/chio/parse.y +++ b/bin/chio/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.13 2008/02/27 16:07:20 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.14 2009/03/31 21:03:48 tobias Exp $ */ /* * Copyright (c) 2006 Bob Beck <beck@openbsd.org> @@ -387,9 +387,12 @@ pushfile(const char *name) { struct file *nfile; - if ((nfile = calloc(1, sizeof(struct file))) == NULL || - (nfile->name = strdup(name)) == NULL) + if ((nfile = calloc(1, sizeof(struct file))) == NULL) return (NULL); + if ((nfile->name = strdup(name)) == NULL) { + free(nfile); + return (NULL); + } if ((nfile->stream = fopen(nfile->name, "r")) == NULL) { free(nfile->name); free(nfile); |