| Ticket UUID: | cee095ab5a4046323c2aafa0d3525d37696ca2c8 | |||
| Title: | X error handler not uninstalled in tkUnixRFont.c, Tk_MeasureChars | |||
| Type: | Bug | Version: | 8.6.12 | |
| Submitter: | sysadm@prs.de | Created on: | 2023-01-06 13:35:33 | |
| Subsystem: | 46. Unix Fonts | Assigned To: | jan.nijtmans | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2024-02-29 22:03:46 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2024-02-29 22:03:46 | |||
| Description: |
Tk_MeasureChars installs an X error handler when called but does not uninstall it in case of the unlikely "this can't happen"-case.
Yes, this case is unlinkely but can be forced by calling the function with an invalid UTF8 sequence.
The corrected code should be:
handler = Tk_CreateErrorHandler(fontPtr->display,
-1, -1, -1, InitFontErrorProc, &errorFlag);
curX = 0;
curByte = 0;
sawNonSpace = 0;
while (numBytes > 0) {
int unichar;
clen = TkUtfToUniChar(source, &unichar);
c = (FcChar32) unichar;
if (clen <= 0) {
/*
* This can't happen (but see #1185640)
*/
*lengthPtr = curX;
/* !!!! NEXT LINE ADDED FOR CORRECTNESS !!!! */
Tk_DeleteErrorHandler(handler);
return curByte;
}
If the case can never happen, the code to check the impossible condition should be removed.
| |||
| User Comments: |
fvogel added on 2024-02-29 22:03:46:
Yes I think so, despite it's not immediately apparent since [af53acf25d036fa1] does not *only* do what the commit says (not a good practice in my opinion). dgp added on 2024-02-28 19:08:21: https://core.tcl-lang.org/tk/info/af53acf25d036fa1 says this is fixed. Close? | |||