Fixed memory leak when reading the stream video descriptors array in

Mac.
This commit is contained in:
Gonzalo Exequiel Pedone 2020-06-25 20:43:52 -03:00
parent d2e2e41637
commit 08c6217c46
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF

View file

@ -575,11 +575,26 @@ bool AkVCam::ObjectProperties::getProperty(UInt32 property,
CFArrayRef array = nullptr;
if (!formats.empty())
if (!formats.empty()) {
CFArrayCallBacks callbacks;
memset(&callbacks, 0, sizeof(CFArrayCallBacks));
callbacks.retain = [] (CFAllocatorRef allocator,
const void *value) -> const void * {
UNUSED(allocator)
return CFRetain(CMFormatDescriptionRef(value));
};
callbacks.release = [] (CFAllocatorRef allocator,
const void *value) {
UNUSED(allocator)
CFRelease(CMFormatDescriptionRef(value));
};
array = CFArrayCreate(kCFAllocatorDefault,
reinterpret_cast<const void **>(formats.data()),
UInt32(formats.size()),
nullptr);
&callbacks);
}
*static_cast<CFArrayRef *>(data) = array;
}