summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2009-07-24 16:51:28 (GMT)
committerandreas_kupries <akupries@shaw.ca>2009-07-24 16:51:28 (GMT)
commit410f05ea0612ecb96c5833d16c0a8216bcd7fb08 (patch)
tree46460d38d87914523bd6bb35a8746c8557614f71
parent8bed03c8ab1a815791db5f01335cccb517cf8bce (diff)
downloadtcl-410f05ea0612ecb96c5833d16c0a8216bcd7fb08.zip
tcl-410f05ea0612ecb96c5833d16c0a8216bcd7fb08.tar.gz
tcl-410f05ea0612ecb96c5833d16c0a8216bcd7fb08.tar.bz2
* generic/tclIO.c (Tcl_GetChannelHandle): [Bug 2826248]: Do not crash
* generic/tclPipe.c (FileForRedirect): for getHandleProc == NULL, this is allowed. Provide a nice error message in the bypass area. Updated caller to check the bypass for a mesage. Bug reported by Andy Sonnenburg <andy22286@users.sourceforge.net>. Backported from CVS head.
-rw-r--r--ChangeLog9
-rw-r--r--generic/tclIO.c10
-rw-r--r--generic/tclPipe.c14
3 files changed, 28 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4294ed0..527fa3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-07-24 Andreas Kupries <andreask@activestate.com>
+
+ * generic/tclIO.c (Tcl_GetChannelHandle): [Bug 2826248]: Do not crash
+ * generic/tclPipe.c (FileForRedirect): for getHandleProc == NULL, this
+ is allowed. Provide a nice error message in the bypass area. Updated
+ caller to check the bypass for a mesage. Bug reported by Andy
+ Sonnenburg <andy22286@users.sourceforge.net>. Backported from CVS
+ head.
+
2009-07-23 Joe Mistachkin <joe@mistachkin.com>
* generic/tclNotify.c: Fix for [Bug 2820349].
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 3553286..649e31b 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.137.2.10 2008/12/11 17:27:39 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.137.2.11 2009/07/24 16:51:28 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -2006,6 +2006,14 @@ Tcl_GetChannelHandle(
int result;
chanPtr = ((Channel *) chan)->state->bottomChanPtr;
+ if (!chanPtr->typePtr->getHandleProc) {
+ Tcl_Obj* err;
+ TclNewLiteralStringObj(err, "channel \"");
+ Tcl_AppendToObj(err, Tcl_GetChannelName(chan), -1);
+ Tcl_AppendToObj(err, "\" does not support OS handles", -1);
+ Tcl_SetChannelError (chan,err);
+ return TCL_ERROR;
+ }
result = (chanPtr->typePtr->getHandleProc)(chanPtr->instanceData,
direction, &handle);
if (handlePtr) {
diff --git a/generic/tclPipe.c b/generic/tclPipe.c
index 561d390..90b1c1a 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.19 2007/04/20 06:10:58 kennykb Exp $
+ * RCS: @(#) $Id: tclPipe.c,v 1.19.4.1 2009/07/24 16:51:28 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -102,9 +102,15 @@ FileForRedirect(
}
file = TclpMakeFile(chan, writing ? TCL_WRITABLE : TCL_READABLE);
if (file == NULL) {
- Tcl_AppendResult(interp, "channel \"", Tcl_GetChannelName(chan),
- "\" wasn't opened for ",
- ((writing) ? "writing" : "reading"), NULL);
+ Tcl_Obj* msg;
+ Tcl_GetChannelError(chan, &msg);
+ if (msg) {
+ Tcl_SetObjResult (interp, msg);
+ } else {
+ Tcl_AppendResult(interp, "channel \"", Tcl_GetChannelName(chan),
+ "\" wasn't opened for ",
+ ((writing) ? "writing" : "reading"), NULL);
+ }
return NULL;
}
*releasePtr = 1;