Module Name: src
Committed By: joerg
Date: Thu Jun 14 18:56:55 UTC 2012
Modified Files:
src/bin/sh: eval.c
Log Message:
Make sure temp_path is always initialised, even if mklocal fails.
Make sure to restore localvars, even if possibly leaking memory.
Discussed with christos@
To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/bin/sh/eval.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/eval.c
diff -u src/bin/sh/eval.c:1.103 src/bin/sh/eval.c:1.104
--- src/bin/sh/eval.c:1.103 Mon Nov 14 18:24:45 2011
+++ src/bin/sh/eval.c Thu Jun 14 18:56:54 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: eval.c,v 1.103 2011/11/14 18:24:45 christos Exp $ */
+/* $NetBSD: eval.c,v 1.104 2012/06/14 18:56:54 joerg Exp $ */
/*-
* Copyright (c) 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#else
-__RCSID("$NetBSD: eval.c,v 1.103 2011/11/14 18:24:45 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.104 2012/06/14 18:56:54 joerg Exp $");
#endif
#endif /* not lint */
@@ -984,6 +984,7 @@ normal_fork:
savehandler = handler;
savecmdname = commandname;
handler = &jmploc;
+ temp_path = 0;
if (!setjmp(jmploc.loc)) {
/* We need to ensure the command hash table isn't
* corruped by temporary PATH assignments.
@@ -993,10 +994,9 @@ normal_fork:
cmdentry.u.bltin == typecmd)) {
savelocalvars = localvars;
localvars = 0;
- mklocal(path - 5 /* PATH= */, 0);
temp_path = 1;
- } else
- temp_path = 0;
+ mklocal(path - 5 /* PATH= */, 0);
+ }
redirect(cmd->ncmd.redirect, mode);
/* exec is a special builtin, but needs this list... */