Skip to content
Permalink
Browse files
Possible CFArray leak in MediaPlayerPrivateAVFoundationCF.cpp
https://bugs.webkit.org/show_bug.cgi?id=148668

Patch by Joseph Pecoraro <pecoraro@apple.com> 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.

Canonical link: https://commits.webkit.org/166787@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189209 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JosephPecoraro authored and webkit-commit-queue committed Sep 1, 2015
1 parent 686a17a commit 511b786153a57de33962e50f5dc5737d23e1306c
Showing 2 changed files with 28 additions and 30 deletions.
@@ -1,3 +1,23 @@
2015-09-01 Joseph Pecoraro <pecoraro@apple.com>

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 <jfernandez@igalia.com>

[CSS Grid Layout] Layout is wrong for flex factor sum between 0 and 1
@@ -872,33 +872,6 @@ void MediaPlayerPrivateAVFoundationCF::paint(GraphicsContext& context, const Flo
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 const HashSet<String>& avfMIMETypes()
{
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 @@ static const HashSet<String>& avfMIMETypes()
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 @@ MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationCF::supportsType(const M
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 @@ bool MediaPlayerPrivateAVFoundationCF::supportsKeySystem(const String& keySystem
if (!keySystemIsSupported(keySystem))
return false;

if (!mimeType.isEmpty() && !mimeTypeCache().contains(mimeType))
if (!mimeType.isEmpty() && !avfMIMETypes().contains(mimeType))
return false;

return true;

0 comments on commit 511b786

Please sign in to comment.