summaryrefslogtreecommitdiffstats
path: root/library/safe.tcl
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-12-30 22:20:57 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-12-30 22:20:57 (GMT)
commit0b28413e2a45ca7e7b0fc35a015b7ef8af931826 (patch)
treec570d2f38edafbc870de694b2fb3864c85ac8a10 /library/safe.tcl
parente0a526e0845027a3332645c718bb528d55bba601 (diff)
downloadtcl-0b28413e2a45ca7e7b0fc35a015b7ef8af931826.zip
tcl-0b28413e2a45ca7e7b0fc35a015b7ef8af931826.tar.gz
tcl-0b28413e2a45ca7e7b0fc35a015b7ef8af931826.tar.bz2
[Bug 2923613]: Make the safer [source] handle a [return] at the end of the file
correctly.
Diffstat (limited to 'library/safe.tcl')
-rw-r--r--library/safe.tcl14
1 files changed, 8 insertions, 6 deletions
diff --git a/library/safe.tcl b/library/safe.tcl
index 4bee33b..e89ca29 100644
--- a/library/safe.tcl
+++ b/library/safe.tcl
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: safe.tcl,v 1.16.4.5 2009/12/23 11:13:46 dkf Exp $
+# RCS: @(#) $Id: safe.tcl,v 1.16.4.6 2009/12/30 22:20:57 dkf Exp $
#
# The implementation is based on namespaces. These naming conventions are
@@ -841,7 +841,7 @@ proc ::safe::AliasSource {slave args} {
# because we want to control [info script] in the slave so information
# doesn't leak so much. [Bug 2913625]
set old [::interp eval $slave {info script}]
- if {[catch {
+ set code [catch {
set f [open $realfile]
fconfigure $f -eofchar \032
if {$encoding ne ""} {
@@ -851,13 +851,15 @@ proc ::safe::AliasSource {slave args} {
close $f
::interp eval $slave [list info script $file]
::interp eval $slave $contents
- } msg]} {
- catch {interp eval $slave [list info script $old]}
+ } msg opt]
+ catch {interp eval $slave [list info script $old]}
+ # Note that all non-errors are fine result codes from [source], so we must
+ # take a little care to do it properly. [Bug 2923613]
+ if {$code == 1} {
Log $slave $msg
return -code error "script error"
}
- catch {interp eval $slave [list info script $old]}
- return $msg
+ return -code $code -options $opt $msg
}
# AliasLoad is the target of the "load" alias in safe interpreters.