Tk Source Code

View Ticket
Login
Ticket UUID: 0ce975c57fe4a7cd7471be60ebcc600b2b028154
Title: memcpy() called with pwPtr->panes == NULL
Type: Bug Version: 8.6.12
Submitter: chrstphrchvz Created on: 2022-05-08 10:30:16
Subsystem: 21. [panedwindow] Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2022-05-08 20:06:14
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2022-05-08 20:06:14
Description:

The first time a window is added to a (non-Ttk) panedwindow, memcpy() gets called with pwPtr->panes == NULL, which is undefined behavior (even though pwPtr->numPanes == 0), and detected by UBSan (-fsanitize=nonnull-attribute) when using glibc:

tk/generic/tkPanedWindow.c:1019:2: runtime error: null pointer passed as argument 2, which is declared to never be null
I would suggest to guard memcpy() with something like if (pwPtr->numPanes != 0) (even though I am aware that panedwindow has other design issues which might not make it worth maintaining).

User Comments: jan.nijtmans added on 2022-05-08 20:06:14:

Hi @fvogel. I just committed the fix too, after committing saw that you did it too. So, I merged your comment too, then this can be closed.

Thanks!


fvogel added on 2022-05-08 19:44:45:

Thank you for this report. I understand the case and have committed your proposal with two lines of explanation in [ad9f506152].