Tk Source Code

View Ticket
Login
Ticket UUID: e331bc470867ed53c64ff8c11781fa68e5b99f42
Title: memset(NULL, …) called in Tk_PhotoBlank()
Type: Bug Version: 8.6.12
Submitter: chrstphrchvz Created on: 2022-02-10 22:40:46
Subsystem: 41. Photo Images Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2022-02-11 15:10:10
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2022-02-11 15:10:10
Description:

Passing NULL as the destination for memset() is undefined behavior. GCC UBSan (-fsanitize=nonnull-attribute) reports this occurring when modelPtr->pix32 is NULL:

% image create photo p0
p0
% p0 blank
tk/generic/tkImgPhoto.c:3619:5: runtime error: null pointer passed as argument 1, which is declared to never be null

Presumably memset() should be guarded by a NULL check, unless returning early is an option.

User Comments: jan.nijtmans added on 2022-02-11 15:10:10:

Fixed now. Thanks!