summaryrefslogtreecommitdiffstats
path: root/generic/tclEvent.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-28 18:17:58 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-28 18:17:58 (GMT)
commite256747736aa11afd1f0908378163f50a918451e (patch)
tree734cf87106d33feb1d361af54d144f31f636640a /generic/tclEvent.c
parent813a5e93acee11fd4652683370c0c7b781b9b353 (diff)
parente2e75c4389e2535cb9a46fd23e020aa35cce7887 (diff)
downloadtcl-e256747736aa11afd1f0908378163f50a918451e.zip
tcl-e256747736aa11afd1f0908378163f50a918451e.tar.gz
tcl-e256747736aa11afd1f0908378163f50a918451e.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclEvent.c')
-rw-r--r--generic/tclEvent.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index 196b615..4365984 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.c
@@ -97,6 +97,8 @@ static int inExit = 0;
static int subsystemsInitialized = 0;
+static const char ENCODING_ERROR[] = "\n\t(encoding error in stderr)";
+
/*
* This variable contains the application wide exit handler. It will be called
* by Tcl_Exit instead of the C-runtime exit if this variable is set to a
@@ -283,9 +285,13 @@ HandleBgErrors(
Tcl_WriteChars(errChannel,
"error in background error handler:\n", -1);
if (valuePtr) {
- Tcl_WriteObj(errChannel, valuePtr);
+ if (Tcl_WriteObj(errChannel, valuePtr) < 0) {
+ Tcl_WriteChars(errChannel, ENCODING_ERROR, -1);
+ }
} else {
- Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp));
+ if (Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)) < 0) {
+ Tcl_WriteChars(errChannel, ENCODING_ERROR, -1);
+ }
}
Tcl_WriteChars(errChannel, "\n", 1);
Tcl_Flush(errChannel);
@@ -472,18 +478,22 @@ TclDefaultBgErrorHandlerObjCmd(
if (Tcl_FindCommand(interp, "bgerror", NULL,
TCL_GLOBAL_ONLY) == NULL) {
Tcl_RestoreInterpState(interp, saved);
- Tcl_WriteObj(errChannel, Tcl_GetVar2Ex(interp,
- "errorInfo", NULL, TCL_GLOBAL_ONLY));
+ if (Tcl_WriteObj(errChannel, Tcl_GetVar2Ex(interp,
+ "errorInfo", NULL, TCL_GLOBAL_ONLY)) < 0) {
+ Tcl_WriteChars(errChannel, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(errChannel, "\n", -1);
} else {
Tcl_DiscardInterpState(saved);
- Tcl_WriteChars(errChannel,
- "bgerror failed to handle background error.\n", -1);
- Tcl_WriteChars(errChannel, " Original error: ", -1);
- Tcl_WriteObj(errChannel, tempObjv[1]);
- Tcl_WriteChars(errChannel, "\n", -1);
- Tcl_WriteChars(errChannel, " Error in bgerror: ", -1);
- Tcl_WriteObj(errChannel, resultPtr);
+ Tcl_WriteChars(errChannel, "bgerror failed to handle"
+ " background error.\n Original error: ", -1);
+ if (Tcl_WriteObj(errChannel, tempObjv[1]) < 0) {
+ Tcl_WriteChars(errChannel, ENCODING_ERROR, -1);
+ }
+ Tcl_WriteChars(errChannel, "\n Error in bgerror: ", -1);
+ if (Tcl_WriteObj(errChannel, resultPtr) < 0) {
+ Tcl_WriteChars(errChannel, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(errChannel, "\n", -1);
}
Tcl_DecrRefCount(resultPtr);