summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-04-30 19:54:51 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-04-30 19:54:51 (GMT)
commit1c909a3352991d577a7164d5bb33dbe8d295ae67 (patch)
treeacaeb4805a0e2fcbd41822f04c25627ccf73c65b /generic/tclIO.c
parent1264e873bbaae9d4328826b749e459e88b32e820 (diff)
downloadtcl-1c909a3352991d577a7164d5bb33dbe8d295ae67.zip
tcl-1c909a3352991d577a7164d5bb33dbe8d295ae67.tar.gz
tcl-1c909a3352991d577a7164d5bb33dbe8d295ae67.tar.bz2
Stop the segfaults in [close] during [gets] tests.
Not sure this is the right behavior, but it's better than crashing.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 0c9db67..cd28a0e 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -4163,12 +4163,12 @@ Tcl_GetsObj(
restore:
bufPtr = statePtr->inQueueHead;
- if (bufPtr == NULL) {
- Tcl_Panic("Tcl_GetsObj: restore reached with bufPtr==NULL");
+ if (bufPtr != NULL) {
+ bufPtr->nextRemoved = oldRemoved;
+ bufPtr = bufPtr->nextPtr;
}
- bufPtr->nextRemoved = oldRemoved;
- for (bufPtr = bufPtr->nextPtr; bufPtr != NULL; bufPtr = bufPtr->nextPtr) {
+ for ( ; bufPtr != NULL; bufPtr = bufPtr->nextPtr) {
bufPtr->nextRemoved = BUFFER_PADDING;
}
CommonGetsCleanup(chanPtr);
@@ -4298,6 +4298,9 @@ TclGetsObjBinary(
goto restore;
}
bufPtr = statePtr->inQueueTail;
+ if (bufPtr == NULL) {
+ goto restore;
+ }
}
dst = (unsigned char *) RemovePoint(bufPtr);
@@ -4410,12 +4413,12 @@ TclGetsObjBinary(
restore:
bufPtr = statePtr->inQueueHead;
- if (bufPtr == NULL) {
- Tcl_Panic("TclGetsObjBinary: restore reached with bufPtr==NULL");
+ if (bufPtr) {
+ bufPtr->nextRemoved = oldRemoved;
+ bufPtr = bufPtr->nextPtr;
}
- bufPtr->nextRemoved = oldRemoved;
- for (bufPtr = bufPtr->nextPtr; bufPtr != NULL; bufPtr = bufPtr->nextPtr) {
+ for ( ; bufPtr != NULL; bufPtr = bufPtr->nextPtr) {
bufPtr->nextRemoved = BUFFER_PADDING;
}
CommonGetsCleanup(chanPtr);
@@ -4571,7 +4574,9 @@ FilterInputBytes(
bufPtr = statePtr->inQueueTail;
gsPtr->bufPtr = bufPtr;
if (bufPtr == NULL) {
- Tcl_Panic("GetInput nuked buffers!");
+ gsPtr->charsWrote = 0;
+ gsPtr->rawRead = 0;
+ return -1;
}
}