Commit 30bc21a1 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Fix leak in VideoCaptureDeviceMac

CFNumberCreate creates with a reference, so existing code leaks.
Switch to non-leaking code.

Bug: none
Change-Id: I14c112cfba220911754110009cf6a080d067743c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392696
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804428}
parent ebe7831a
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_ioobject.h" #include "base/mac/scoped_ioobject.h"
#include "base/mac/scoped_ioplugininterface.h" #include "base/mac/scoped_ioplugininterface.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -252,18 +254,16 @@ static void SetAntiFlickerInUsbDevice(const int vendor_id, ...@@ -252,18 +254,16 @@ static void SetAntiFlickerInUsbDevice(const int vendor_id,
<< " Hz, device " << std::hex << vendor_id << "-" << product_id; << " Hz, device " << std::hex << vendor_id << "-" << product_id;
// Compose a search dictionary with vendor and product ID. // Compose a search dictionary with vendor and product ID.
CFMutableDictionaryRef query_dictionary = base::ScopedCFTypeRef<CFMutableDictionaryRef> query_dictionary(
IOServiceMatching(kIOUSBDeviceClassName); IOServiceMatching(kIOUSBDeviceClassName));
CFDictionarySetValue( CFDictionarySetValue(query_dictionary, CFSTR(kUSBVendorName),
query_dictionary, CFSTR(kUSBVendorName), base::mac::NSToCFCast(@(vendor_id)));
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vendor_id)); CFDictionarySetValue(query_dictionary, CFSTR(kUSBProductName),
CFDictionarySetValue( base::mac::NSToCFCast(@(product_id)));
query_dictionary, CFSTR(kUSBProductName),
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &product_id));
io_iterator_t usb_iterator; io_iterator_t usb_iterator;
kern_return_t kr = IOServiceGetMatchingServices( kern_return_t kr = IOServiceGetMatchingServices(
kIOMasterPortDefault, query_dictionary, &usb_iterator); kIOMasterPortDefault, query_dictionary.release(), &usb_iterator);
if (kr != kIOReturnSuccess) { if (kr != kIOReturnSuccess) {
DLOG(ERROR) << "No devices found with specified Vendor and Product ID."; DLOG(ERROR) << "No devices found with specified Vendor and Product ID.";
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment