summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbch <brad.harder@gmail.com>2015-02-19 19:19:42 (GMT)
committerbch <brad.harder@gmail.com>2015-02-19 19:19:42 (GMT)
commitf345178cb757d71c313cff5880a44fc3d90188e4 (patch)
tree6554159d5633945afa879a547cb95a3ee44cba6d
parentc9d86d95ddb0e13b6c17589f0598cb6492cbda48 (diff)
parent44aa000539d0865e99c9bc3f4d4c2984d1eeb876 (diff)
downloadtcl-f345178cb757d71c313cff5880a44fc3d90188e4.zip
tcl-f345178cb757d71c313cff5880a44fc3d90188e4.tar.gz
tcl-f345178cb757d71c313cff5880a44fc3d90188e4.tar.bz2
Do not fault! Tcl_Panic()! - improvements to handling Tcl_CreateChannel() args
-rw-r--r--generic/tclIO.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 86ec27a..aabae0b 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -1548,6 +1548,25 @@ Tcl_CreateChannel(
*/
assert(sizeof(Tcl_ChannelTypeVersion) == sizeof(Tcl_DriverBlockModeProc *));
+ assert(typePtr->typeName != NULL);
+ if (NULL == typePtr->closeProc) {
+ Tcl_Panic("channel type %s must define closeProc", typePtr->typeName);
+ }
+ if ((TCL_READABLE & mask) && (NULL == typePtr->inputProc)) {
+ Tcl_Panic("channel type %s must define inputProc when used for reader channel", typePtr->typeName);
+ }
+ if ((TCL_WRITABLE & mask) && (NULL == typePtr->outputProc)) {
+ Tcl_Panic("channel type %s must define outputProc when used for writer channel", typePtr->typeName);
+ }
+ if (NULL == typePtr->watchProc) {
+ Tcl_Panic("channel type %s must define watchProc", typePtr->typeName);
+ }
+ if (NULL == typePtr->getHandleProc) {
+ Tcl_Panic("channel type %s must define getHandleProc", typePtr->typeName);
+ }
+ if ((NULL!=typePtr->wideSeekProc) && (NULL == typePtr->seekProc)) {
+ Tcl_Panic("channel type %s must define seekProc if defining wideSeekProc", typePtr->typeName);
+ }
/*
* JH: We could subsequently memset these to 0 to avoid the numerous