Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Make sure temp_path is always initialised, even if mk...



details:   https://anonhg.NetBSD.org/src/rev/0e2fdde71f46
branches:  trunk
changeset: 779736:0e2fdde71f46
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Jun 14 18:56:54 2012 +0000

description:
Make sure temp_path is always initialised, even if mklocal fails.
Make sure to restore localvars, even if possibly leaking memory.
Discussed with christos@

diffstat:

 bin/sh/eval.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (39 lines):

diff -r 5590630f00ee -r 0e2fdde71f46 bin/sh/eval.c
--- a/bin/sh/eval.c     Thu Jun 14 17:47:58 2012 +0000
+++ b/bin/sh/eval.c     Thu Jun 14 18:56:54 2012 +0000
@@ -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 @@
                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 @@
                            cmdentry.u.bltin == typecmd)) {
                                savelocalvars = localvars;
                                localvars = 0;
+                               temp_path = 1;
                                mklocal(path - 5 /* PATH= */, 0);
-                               temp_path = 1;
-                       } else
-                               temp_path = 0;
+                       }
                        redirect(cmd->ncmd.redirect, mode);
 
                        /* exec is a special builtin, but needs this list... */



Home | Main Index | Thread Index | Old Index