From 73cefe9821b18e74d301da6d70d9d2709cacfe7f Mon Sep 17 00:00:00 2001 From: rmax Date: Mon, 16 Jan 2006 19:38:15 +0000 Subject: * generic/tclPipe.c (FileForRedirect): Prevent nameString from being freed without having been initialized. * tests/exec.test: Added a test for the above. --- ChangeLog | 6 ++++++ generic/tclPipe.c | 9 ++++----- tests/exec.test | 8 ++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a76775..eabb6a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-01-16 Reinhard Max + + * generic/tclPipe.c (FileForRedirect): Prevent nameString from + being freed without having been initialized. + * tests/exec.test: Added a test for the above. + 2006-01-12 Zoran Vasiljevic * generic/tclPathObj.c (Tcl_FSGetInternalRep): backported diff --git a/generic/tclPipe.c b/generic/tclPipe.c index 3cec10c..b02d91b 100644 --- a/generic/tclPipe.c +++ b/generic/tclPipe.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclPipe.c,v 1.16 2005/11/07 08:56:27 dkf Exp $ + * RCS: @(#) $Id: tclPipe.c,v 1.17 2006/01/16 19:38:15 rmax Exp $ */ #include "tclInt.h" @@ -128,11 +128,10 @@ FileForRedirect( *skipPtr = 2; } name = Tcl_TranslateFileName(interp, spec, &nameString); - if (name != NULL) { - file = TclpOpenFile(name, flags); - } else { - file = NULL; + if (name == NULL) { + return NULL; } + file = TclpOpenFile(name, flags); Tcl_DStringFree(&nameString); if (file == NULL) { Tcl_AppendResult(interp, "couldn't ", diff --git a/tests/exec.test b/tests/exec.test index 6575bf6..b43da60 100644 --- a/tests/exec.test +++ b/tests/exec.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: exec.test,v 1.24 2005/11/04 23:01:40 patthoyts Exp $ +# RCS: @(#) $Id: exec.test,v 1.25 2006/01/16 19:38:15 rmax Exp $ package require tcltest 2 namespace import -force ::tcltest::* @@ -402,7 +402,11 @@ test exec-10.20 {errors in exec invocation} {exec} { test exec-10.21 {errors in exec invocation} {exec} { list [catch {exec [interpreter] true | ~xyzzy_bad_user/x | false} msg] $msg } {1 {user "xyzzy_bad_user" doesn't exist}} - +test exec-10.22 {errors in exec invocation} \ +-constraints exec \ +-returnCodes 1 \ +-body {exec echo test > ~non_existent_user/foo/bar} \ +-result {user "non_existent_user" doesn't exist} # Commands in background. test exec-11.1 {commands in background} {exec} { -- cgit v0.12