Avoid memory leak in error case. From Gao Ya'nan in PR bin/39721.

This commit is contained in:
dholland 2008-10-09 07:18:15 +00:00
parent 65d9dac7ee
commit 3251535c47
1 changed files with 4 additions and 2 deletions

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: scan.l,v 1.10 2008/06/10 12:35:32 drochner Exp $ */
/* $NetBSD: scan.l,v 1.11 2008/10/09 07:18:15 dholland Exp $ */
/*
* Copyright (c) 1992, 1993
@ -387,8 +387,10 @@ curdir_push(const char *fname)
else {
char *cwd, buf[PATH_MAX];
if ((cwd = getcwd(buf, sizeof(buf))) == NULL)
if ((cwd = getcwd(buf, sizeof(buf))) == NULL) {
free(f);
return (-1);
}
p = emalloc(strlen(cwd) + strlen(d) + 2);
sprintf(p, "%s/%s", cwd, d);
}