summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2023-11-13 16:19:14 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2023-11-13 16:19:14 (GMT)
commit7dc00ec38253f4d88e8206e130b1083d0bedeb6d (patch)
tree39b1d3f6188435e4cef8f7f236a006ce2dc64cc9 /generic/tclIO.c
parent6caba0a0e6bb6f880cb53413b2f7dfaf6320fb12 (diff)
parentd0863453ccc9e881f12f9015c72a94533dec5267 (diff)
downloadtcl-7dc00ec38253f4d88e8206e130b1083d0bedeb6d.zip
tcl-7dc00ec38253f4d88e8206e130b1083d0bedeb6d.tar.gz
tcl-7dc00ec38253f4d88e8206e130b1083d0bedeb6d.tar.bz2
Bug [c4eb46a1]: endless loop on non blocking gets with encoding error. No additional failing tests.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index c5e6365..e0bee2b 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -4692,6 +4692,12 @@ Tcl_GetsObj(
ResetFlag(statePtr, CHANNEL_BLOCKED);
while (1) {
if (dst >= dstEnd) {
+ /*
+ * In case of encoding errors, state gets flag
+ * CHANNEL_ENCODING_ERROR set in the call below. First, the
+ * EOF/EOL condition is checked, as we may have valid data with
+ * EOF/EOL before the encoding error.
+ */
if (FilterInputBytes(chanPtr, &gs) != 0) {
goto restore;
}
@@ -4861,8 +4867,17 @@ Tcl_GetsObj(
}
goto gotEOL;
} else if (gs.bytesWrote == 0
- && GotFlag(statePtr, CHANNEL_ENCODING_ERROR)
- && !GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
+ && GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) {
+ /* Ticket c4eb46a1 Harald Oehlmann 2023-11-12 debugging session.
+ * In non blocking mode we loop indifenitly on a decoding error in
+ * this while-loop.
+ * Removed the following from the upper condition:
+ * "&& !GotFlag(statePtr, CHANNEL_NONBLOCKING)"
+ * In case of an encoding error with leading correct bytes, we pass here
+ * two times, as gs.bytesWrote is not 0 on the first pass. This feels
+ * once to much, as the data is anyway not used.
+ */
+
/* Set eol to the position that caused the encoding error, and then
* continue to gotEOL, which stores the data that was decoded
* without error to objPtr. This allows the caller to do something