WebKit Bugzilla
Attachment 341681 Details for
Bug 186152
: Fix leak of AudioDeviceID array due to an early return in AudioDeviceMac::GetNumberDevices()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v2
bug-186152-20180531120403.patch (text/plain), 5.65 KB, created by
David Kilzer (:ddkilzer)
on 2018-05-31 12:04:03 PDT
(
hide
)
Description:
Patch v2
Filename:
MIME Type:
Creator:
David Kilzer (:ddkilzer)
Created:
2018-05-31 12:04:03 PDT
Size:
5.65 KB
patch
obsolete
>Subversion Revision: 232357 >diff --git a/Source/ThirdParty/libwebrtc/ChangeLog b/Source/ThirdParty/libwebrtc/ChangeLog >index e18bc5a3221c87f70eaa8ba2c5c89ee50cfbecc2..c183bdc43443f55c929f38d1ce08a26c5ecf6b57 100644 >--- a/Source/ThirdParty/libwebrtc/ChangeLog >+++ b/Source/ThirdParty/libwebrtc/ChangeLog >@@ -1,3 +1,16 @@ >+2018-05-31 David Kilzer <ddkilzer@apple.com> >+ >+ Fix leak of AudioDeviceID array due to an early return in AudioDeviceMac::GetNumberDevices() >+ <https://webkit.org/b/186152> >+ <rdar://problem/40692824> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Source/webrtc/modules/audio_device/mac/audio_device_mac.cc: >+ Use std::make_unique<> so that memory is allocated and >+ deallocated automatically. Remove manual calls to free(). >+ * WebKit/0011-Fix-AudioDeviceID-array-leak.patch: Add. >+ > 2018-05-30 David Kilzer <ddkilzer@apple.com> > > Fix leak of a CVPixelBufferRef due to early rerturn in -[RTCVideoEncoderH264 encode:codecSpecificInfo:frameTypes:] >diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc b/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc >index c585c32cafc30f40c2dd00bc909649876da20d6a..ee4ed076fe7f4f938b3e32a913ed1352f67ed6a7 100644 >--- a/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc >+++ b/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc >@@ -19,6 +19,7 @@ > #include <ApplicationServices/ApplicationServices.h> > #include <libkern/OSAtomic.h> // OSAtomicCompareAndSwap() > #include <mach/mach.h> // mach_task_self() >+#include <memory> // std::make_unique<>() and std::unique_ptr<>() > #include <sys/sysctl.h> // sysctlbyname() > > namespace webrtc { >@@ -1564,8 +1565,8 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, > return 0; > } > >- AudioDeviceID* deviceIds = (AudioDeviceID*)malloc(size); >- UInt32 numberDevices = size / sizeof(AudioDeviceID); >+ const UInt32 numberDevices = size / sizeof(AudioDeviceID); >+ auto deviceIds = std::make_unique<AudioDeviceID[]>(numberDevices); > AudioBufferList* bufferList = NULL; > UInt32 numberScopedDevices = 0; > >@@ -1597,7 +1598,7 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, > bool listOK = true; > > WEBRTC_CA_LOG_ERR(AudioObjectGetPropertyData( >- kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, deviceIds)); >+ kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, deviceIds.get())); > if (err != noErr) { > listOK = false; > } else { >@@ -1641,11 +1642,6 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, > } > > if (!listOK) { >- if (deviceIds) { >- free(deviceIds); >- deviceIds = NULL; >- } >- > if (bufferList) { > free(bufferList); > bufferList = NULL; >@@ -1654,12 +1650,6 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, > return -1; > } > >- // Happy ending >- if (deviceIds) { >- free(deviceIds); >- deviceIds = NULL; >- } >- > return numberScopedDevices; > } > >diff --git a/Source/ThirdParty/libwebrtc/WebKit/0011-Fix-AudioDeviceID-array-leak.patch b/Source/ThirdParty/libwebrtc/WebKit/0011-Fix-AudioDeviceID-array-leak.patch >new file mode 100644 >index 0000000000000000000000000000000000000000..71cf48a77bd1def4b7d4ed0cc86e78af29f2910a >--- /dev/null >+++ b/Source/ThirdParty/libwebrtc/WebKit/0011-Fix-AudioDeviceID-array-leak.patch >@@ -0,0 +1,57 @@ >+diff --git a/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc b/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc >+index c585c32cafc..ee4ed076fe7 100644 >+--- a/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc >++++ b/Source/ThirdParty/libwebrtc/Source/webrtc/modules/audio_device/mac/audio_device_mac.cc >+@@ -19,6 +19,7 @@ >+ #include <ApplicationServices/ApplicationServices.h> >+ #include <libkern/OSAtomic.h> // OSAtomicCompareAndSwap() >+ #include <mach/mach.h> // mach_task_self() >++#include <memory> // std::make_unique<>() and std::unique_ptr<>() >+ #include <sys/sysctl.h> // sysctlbyname() >+ >+ namespace webrtc { >+@@ -1564,8 +1565,8 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, >+ return 0; >+ } >+ >+- AudioDeviceID* deviceIds = (AudioDeviceID*)malloc(size); >+- UInt32 numberDevices = size / sizeof(AudioDeviceID); >++ const UInt32 numberDevices = size / sizeof(AudioDeviceID); >++ auto deviceIds = std::make_unique<AudioDeviceID[]>(numberDevices); >+ AudioBufferList* bufferList = NULL; >+ UInt32 numberScopedDevices = 0; >+ >+@@ -1597,7 +1598,7 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, >+ bool listOK = true; >+ >+ WEBRTC_CA_LOG_ERR(AudioObjectGetPropertyData( >+- kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, deviceIds)); >++ kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, deviceIds.get())); >+ if (err != noErr) { >+ listOK = false; >+ } else { >+@@ -1641,11 +1642,6 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, >+ } >+ >+ if (!listOK) { >+- if (deviceIds) { >+- free(deviceIds); >+- deviceIds = NULL; >+- } >+- >+ if (bufferList) { >+ free(bufferList); >+ bufferList = NULL; >+@@ -1654,12 +1650,6 @@ int32_t AudioDeviceMac::GetNumberDevices(const AudioObjectPropertyScope scope, >+ return -1; >+ } >+ >+- // Happy ending >+- if (deviceIds) { >+- free(deviceIds); >+- deviceIds = NULL; >+- } >+- >+ return numberScopedDevices; >+ } >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186152
:
341679
|
341681
|
341684