Attachment "ad5a57f2f271.diff" to
ticket [ad5a57f2f2]
added by
chrstphrchvz
2023-10-12 11:01:59.
diff --git unix/tclUnixChan.c unix/tclUnixChan.c
index 2f512266cd..67f22ff497 100644
--- unix/tclUnixChan.c
+++ unix/tclUnixChan.c
@@ -477,6 +477,20 @@ FileWideSeekProc(
*----------------------------------------------------------------------
*/
+/*
+ * Bug ad5a57f2f271: Tcl_NotifyChannel is not a Tcl_FileProc,
+ * so do not pass it to directly to Tcl_CreateFileHandler.
+ * Instead, pass a wrapper which is a Tcl_FileProc.
+ */
+static void
+FileWatchNotifyChannelWrapper(
+ ClientData clientData,
+ int mask)
+{
+ Tcl_Channel channel = clientData;
+ Tcl_NotifyChannel(channel, mask);
+}
+
static void
FileWatchProc(
ClientData instanceData, /* The file state. */
@@ -487,15 +501,13 @@ FileWatchProc(
FileState *fsPtr = instanceData;
/*
- * Make sure we only register for events that are valid on this file. Note
- * that we are passing Tcl_NotifyChannel directly to Tcl_CreateFileHandler
- * with the channel pointer as the client data.
+ * Make sure we only register for events that are valid on this file.
*/
mask &= fsPtr->validMask;
if (mask) {
Tcl_CreateFileHandler(fsPtr->fd, mask,
- (Tcl_FileProc *) Tcl_NotifyChannel, fsPtr->channel);
+ FileWatchNotifyChannelWrapper, fsPtr->channel);
} else {
Tcl_DeleteFileHandler(fsPtr->fd);
}
diff --git unix/tclUnixPipe.c unix/tclUnixPipe.c
index 96ca095ea1..1dc0c8033b 100644
--- unix/tclUnixPipe.c
+++ unix/tclUnixPipe.c
@@ -1215,6 +1215,20 @@ PipeOutputProc(
*----------------------------------------------------------------------
*/
+/*
+ * Bug ad5a57f2f271: Tcl_NotifyChannel is not a Tcl_FileProc,
+ * so do not pass it to directly to Tcl_CreateFileHandler.
+ * Instead, pass a wrapper which is a Tcl_FileProc.
+ */
+static void
+PipeWatchNotifyChannelWrapper(
+ ClientData clientData,
+ int mask)
+{
+ Tcl_Channel channel = clientData;
+ Tcl_NotifyChannel(channel, mask);
+}
+
static void
PipeWatchProc(
ClientData instanceData, /* The pipe state. */
@@ -1229,7 +1243,7 @@ PipeWatchProc(
newmask = mask & (TCL_READABLE | TCL_EXCEPTION);
if (newmask) {
Tcl_CreateFileHandler(GetFd(psPtr->inFile), newmask,
- (Tcl_FileProc *) Tcl_NotifyChannel, psPtr->channel);
+ PipeWatchNotifyChannelWrapper, psPtr->channel);
} else {
Tcl_DeleteFileHandler(GetFd(psPtr->inFile));
}
@@ -1238,7 +1252,7 @@ PipeWatchProc(
newmask = mask & (TCL_WRITABLE | TCL_EXCEPTION);
if (newmask) {
Tcl_CreateFileHandler(GetFd(psPtr->outFile), newmask,
- (Tcl_FileProc *) Tcl_NotifyChannel, psPtr->channel);
+ PipeWatchNotifyChannelWrapper, psPtr->channel);
} else {
Tcl_DeleteFileHandler(GetFd(psPtr->outFile));
}