Tk Source Code

View Ticket
Login
Ticket UUID: 6c47958804ff5c488508d2478104fc265667312d
Title: leak in XCreateBitmapFromData()
Type: Bug Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2025-09-09 20:47:16
Subsystem: 82. X11 Emulation Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2025-09-13 17:56:09
Resolution: Fixed Closed By: chrstphrchvz
    Closed on: 2025-09-13 17:56:09
Description:

In the unlikely event that XCreateGC() returns NULL, pix is leaked.

Suggested fix:

--- xlib/ximage.c
+++ xlib/ximage.c
@@ -47,6 +47,7 @@ XCreateBitmapFromData(
     pix = Tk_GetPixmap(display, d, (int) width, (int) height, 1);
     gc = XCreateGC(display, pix, 0, NULL);
     if (gc == NULL) {
+	Tk_FreePixmap(display, pix);
 	return None;
     }
     ximage = XCreateImage(display, NULL, 1, XYBitmap, 0, (char*) data, width,

User Comments: chrstphrchvz added on 2025-09-13 17:56:09:

Thanks for reviewing this, Jan!


jan.nijtmans added on 2025-09-12 10:36:27:

+1. Go ahead!