diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2010-02-16 08:02:22 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2010-02-16 08:02:22 +0000 |
commit | 6c7620d6fa425688f777ffe28116e5aa22c10cea (patch) | |
tree | bde7eb79388e59a25b131d367ce23a505a35f5dc /usr.sbin/ldpd/parse.y | |
parent | 9c1d6cb9a2c774e725aa8925053895b0fa43e4d1 (diff) |
Plug a memory leak in pushfile().
ok claudio@
Diffstat (limited to 'usr.sbin/ldpd/parse.y')
-rw-r--r-- | usr.sbin/ldpd/parse.y | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index 534e59a0dcf..68ecc5b8149 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.1 2009/06/01 20:59:45 michele Exp $ */ +/* $OpenBSD: parse.y,v 1.2 2010/02/16 08:02:21 michele Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -641,11 +641,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("strdup"); + free(nfile); + return (NULL); + } if ((nfile->stream = fopen(nfile->name, "r")) == NULL) { log_warn("%s", nfile->name); free(nfile->name); |