Ticket UUID: | 04d3e5ea8eeb0a747f938480202b40dd59a92ed7 | |||
Title: | Ttk_Use(): do not call functions through pointers to incorrect function type | |||
Type: | Patch | Version: | 8.6.13 | |
Submitter: | chrstphrchvz | Created on: | 2023-10-12 09:07:39 | |
Subsystem: | 88. Themed Tk | Assigned To: | nobody | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2023-10-13 18:56:19 | |
Resolution: | Fixed | Closed By: | fvogel | |
Closed on: | 2023-10-13 18:56:19 | |||
Description: |
Ttk_Use() accepts and calls a function pointer allocate whose return type is supposed to be void *, but that does not match the actual return types of the functions called. This triggers UBSan -fsanitize=function errors, e.g.:
tk/generic/ttk/ttkCache.c:270:9: runtime error: call to function Tk_Alloc3DBorderFromObj through pointer to incorrect function type 'void *(*)(struct Tcl_Interp *, struct Tk_Window_ *, struct Tcl_Obj *)'
tk3d.c:87: note: Tk_Alloc3DBorderFromObj defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tk/generic/ttk/ttkCache.c:270:9 in
Since the called functions are public APIs, whereas Ttk_Use() is static and only used 3 times, I propose to have Ttk_Use() use an enum instead of a function pointer, and call the desired function directly; see attached patch. | |||
User Comments: |
fvogel added on 2023-10-13 18:56:19:
Seems to be fixed here: [0dc5b1e1] |
Attachments:
- 04d3e5ea8eeb.diff [download] added by chrstphrchvz on 2023-10-12 09:09:00. [details]