Title: [189209] trunk/Source/WebCore
Revision
189209
Author
[email protected]
Date
2015-09-01 08:49:33 -0700 (Tue, 01 Sep 2015)

Log Message

Possible CFArray leak in MediaPlayerPrivateAVFoundationCF.cpp
https://bugs.webkit.org/show_bug.cgi?id=148668

Patch by Joseph Pecoraro <[email protected]> on 2015-09-01
Reviewed by Eric Carlson.

* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::mimeTypeCache): Deleted.
(WebCore::avfMIMETypes):
Fix the leak in avfMIMETypes. Consolidate on the single implementation.
Note that avfMIMETypes lowercased the inputs and mimeTypeCache did not,
but we now match MediaPlayerPrivateAVFoundationObjC which has one version
that lowercased inputs as well.

(WebCore::MediaPlayerPrivateAVFoundationCF::getSupportedTypes):
(WebCore::MediaPlayerPrivateAVFoundationCF::supportsType):
(WebCore::MediaPlayerPrivateAVFoundationCF::supportsKeySystem):
Convert to th enew verison.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (189208 => 189209)


--- trunk/Source/WebCore/ChangeLog	2015-09-01 15:04:08 UTC (rev 189208)
+++ trunk/Source/WebCore/ChangeLog	2015-09-01 15:49:33 UTC (rev 189209)
@@ -1,3 +1,23 @@
+2015-09-01  Joseph Pecoraro  <[email protected]>
+
+        Possible CFArray leak in MediaPlayerPrivateAVFoundationCF.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=148668
+
+        Reviewed by Eric Carlson.
+
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::mimeTypeCache): Deleted.
+        (WebCore::avfMIMETypes):
+        Fix the leak in avfMIMETypes. Consolidate on the single implementation.
+        Note that avfMIMETypes lowercased the inputs and mimeTypeCache did not,
+        but we now match MediaPlayerPrivateAVFoundationObjC which has one version
+        that lowercased inputs as well.
+
+        (WebCore::MediaPlayerPrivateAVFoundationCF::getSupportedTypes):
+        (WebCore::MediaPlayerPrivateAVFoundationCF::supportsType):
+        (WebCore::MediaPlayerPrivateAVFoundationCF::supportsKeySystem):
+        Convert to th enew verison.
+
 2015-09-01  Javier Fernandez  <[email protected]>
 
         [CSS Grid Layout] Layout is wrong for flex factor sum between 0 and 1

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (189208 => 189209)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2015-09-01 15:04:08 UTC (rev 189208)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2015-09-01 15:49:33 UTC (rev 189209)
@@ -872,33 +872,6 @@
     m_videoFrameHasDrawn = true;
 }
 
-static const HashSet<String>& mimeTypeCache()
-{
-    static NeverDestroyed<HashSet<String>> cache;
-    static bool typeListInitialized = false;
-
-    if (typeListInitialized)
-        return cache;
-    typeListInitialized = true;
-
-    RetainPtr<CFArrayRef> supportedTypes = adoptCF(AVCFURLAssetCopyAudiovisualMIMETypes());
-    
-    ASSERT(supportedTypes);
-    if (!supportedTypes)
-        return cache;
-
-    CFIndex typeCount = CFArrayGetCount(supportedTypes.get());
-    for (CFIndex i = 0; i < typeCount; i++)
-        cache.get().add(static_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i)));
-
-    return cache;
-} 
-
-void MediaPlayerPrivateAVFoundationCF::getSupportedTypes(HashSet<String>& supportedTypes)
-{
-    supportedTypes = mimeTypeCache();
-} 
-
 #if HAVE(AVFOUNDATION_LOADER_DELEGATE) && ENABLE(ENCRYPTED_MEDIA_V2)
 static bool keySystemIsSupported(const String& keySystem)
 {
@@ -912,7 +885,7 @@
 {
     static NeverDestroyed<HashSet<String>> cache = []() {
         HashSet<String> types;
-        RetainPtr<CFArrayRef> avTypes = AVCFURLAssetCopyAudiovisualMIMETypes();
+        RetainPtr<CFArrayRef> avTypes = adoptCF(AVCFURLAssetCopyAudiovisualMIMETypes());
 
         CFIndex typeCount = CFArrayGetCount(avTypes.get());
         for (CFIndex i = 0; i < typeCount; ++i) {
@@ -926,6 +899,11 @@
     return cache;
 }
 
+void MediaPlayerPrivateAVFoundationCF::getSupportedTypes(HashSet<String>& supportedTypes)
+{
+    supportedTypes = avfMIMETypes();
+}
+
 MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationCF::supportsType(const MediaEngineSupportParameters& parameters)
 {
     if (isUnsupportedMIMEType(parameters.type))
@@ -943,7 +921,7 @@
     String typeString = parameters.type + "; codecs=\"" + parameters.codecs + "\"";
     return AVCFURLAssetIsPlayableExtendedMIMEType(typeString.createCFString().get()) ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;
 #else
-    if (mimeTypeCache().contains(parameters.type))
+    if (avfMIMETypes().contains(parameters.type))
         return parameters.codecs.isEmpty() ? MediaPlayer::MayBeSupported : MediaPlayer::IsSupported;
     return MediaPlayer::IsNotSupported;
 #endif
@@ -958,7 +936,7 @@
     if (!keySystemIsSupported(keySystem))
         return false;
 
-    if (!mimeType.isEmpty() && !mimeTypeCache().contains(mimeType))
+    if (!mimeType.isEmpty() && !avfMIMETypes().contains(mimeType))
         return false;
 
     return true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to