From cdacc11624f1e986be2de564526a07c4e1039ae3 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 27 May 2026 23:50:07 +0200 Subject: [PATCH] LibCore: Release IOSurface creation properties IOSurfaceHandle::create() builds a CoreFoundation dictionary for IOSurfaceCreate() and previously left that dictionary alive after the surface was created. Each locally created IOSurface therefore leaked the temporary properties dictionary. --- Libraries/LibCore/IOSurface.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/LibCore/IOSurface.cpp b/Libraries/LibCore/IOSurface.cpp index 36ca631f12..e79deab645 100644 --- a/Libraries/LibCore/IOSurface.cpp +++ b/Libraries/LibCore/IOSurface.cpp @@ -66,17 +66,17 @@ IOSurfaceHandle IOSurfaceHandle::create(int width, int height) RefAutoRelease bytes_per_element_number = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &bytes_per_element); RefAutoRelease pixel_format_number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pixel_format); - CFMutableDictionaryRef props = CFDictionaryCreateMutable(kCFAllocatorDefault, + RefAutoRelease props = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionarySetValue(props, kIOSurfaceWidth, width_number.ref()); - CFDictionarySetValue(props, kIOSurfaceHeight, height_number.ref()); - CFDictionarySetValue(props, kIOSurfaceBytesPerElement, bytes_per_element_number.ref()); - CFDictionarySetValue(props, kIOSurfacePixelFormat, pixel_format_number.ref()); + CFDictionarySetValue(props.ref(), kIOSurfaceWidth, width_number.ref()); + CFDictionarySetValue(props.ref(), kIOSurfaceHeight, height_number.ref()); + CFDictionarySetValue(props.ref(), kIOSurfaceBytesPerElement, bytes_per_element_number.ref()); + CFDictionarySetValue(props.ref(), kIOSurfacePixelFormat, pixel_format_number.ref()); - auto* ref = IOSurfaceCreate(props); + auto* ref = IOSurfaceCreate(props.ref()); VERIFY(ref); return IOSurfaceHandle(make(ref)); }