Diff
Modified: trunk/Source/WebCore/ChangeLog (167745 => 167746)
--- trunk/Source/WebCore/ChangeLog 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/ChangeLog 2014-04-24 04:46:28 UTC (rev 167746)
@@ -1,3 +1,43 @@
+2014-04-23 Darin Adler <da...@apple.com>
+
+ [Cocoa] fix CF leaks found by code inspection
+ https://bugs.webkit.org/show_bug.cgi?id=132106
+
+ Reviewed by Andreas Kling.
+
+ * page/CaptionUserPreferencesMediaAF.cpp:
+ (WebCore::trackDisplayName): Added a missing adoptCF.
+
+ * platform/Language.cpp:
+ (WebCore::displayNameForLanguageLocale): Added a missing adoptCF.
+
+ * platform/graphics/FontPlatformData.cpp:
+ (WebCore::FontPlatformData::openTypeTable): Added a missing adoptCF.
+
+ * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
+ (WebCore::InbandTextTrackPrivateAVCF::label): Added two missing adoptCF.
+
+ * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+ (WebCore::AVFWrapper::createImageForTimeInRect): Added two missing adoptCF.
+
+ * platform/graphics/cg/PDFDocumentImage.cpp:
+ (WebCore::PDFDocumentImage::createPDFDocument): Added missing adoptCF.
+
+ * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+ (WebCore::cascadeToLastResortFontDescriptor): Added two missing adoptCF.
+
+ * platform/graphics/mac/FontMac.mm:
+ (WebCore::Font::primaryFontDataIsSystemFont): Added missing adoptCF.
+
+ * platform/graphics/mac/SimpleFontDataMac.mm:
+ (WebCore::hasCustomTracking): Added missing adoptCF.
+
+ * platform/image-decoders/ImageDecoder.h:
+ (WebCore::ImageDecoder::qcmsOutputDeviceProfile): Added CFRelease.
+
+ * plugins/mac/PluginPackageMac.cpp:
+ (WebCore::readPListFile): Added two missing adoptCF.
+
2014-04-23 Ryosuke Niwa <rn...@webkit.org>
REGRESSION (r157328): popover to check into flight ba.com dismisses instantly when focusing form
Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (167745 => 167746)
--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp 2014-04-24 04:46:28 UTC (rev 167746)
@@ -608,7 +608,7 @@
}
}
} else {
- String languageAndLocale = CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, trackLanguageIdentifier.createCFString().get());
+ String languageAndLocale = adoptCF(CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, trackLanguageIdentifier.createCFString().get())).get();
if (!languageAndLocale.isEmpty())
displayName.append(languageAndLocale);
else if (!language.isEmpty())
Modified: trunk/Source/WebCore/platform/Language.cpp (167745 => 167746)
--- trunk/Source/WebCore/platform/Language.cpp 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/Language.cpp 2014-04-24 04:46:28 UTC (rev 167746)
@@ -148,10 +148,8 @@
String displayNameForLanguageLocale(const String& localeName)
{
#if USE(CF) && !PLATFORM(WIN)
- if (!localeName.isNull() && !localeName.isEmpty()) {
- RetainPtr<CFLocaleRef> currentLocale = adoptCF(CFLocaleCopyCurrent());
- return CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, localeName.createCFString().get());
- }
+ if (!localeName.isEmpty())
+ return adoptCF(CFLocaleCopyDisplayNameForPropertyValue(adoptCF(CFLocaleCopyCurrent()).get(), kCFLocaleIdentifier, localeName.createCFString().get())).get();
#endif
return localeName;
}
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp (167745 => 167746)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2014-04-24 04:46:28 UTC (rev 167746)
@@ -177,8 +177,8 @@
#if OS(DARWIN) && USE(CG)
PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
{
- if (CFDataRef data = "" table))
- return SharedBuffer::wrapCFData(data);
+ if (RetainPtr<CFDataRef> data = "" table)))
+ return SharedBuffer::wrapCFData(data.get());
return nullptr;
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp (167745 => 167746)
--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp 2014-04-24 04:46:28 UTC (rev 167746)
@@ -148,8 +148,8 @@
return emptyAtom;
// If possible, return a title in one of the user's preferred languages.
- RetainPtr<CFArrayRef> preferredLanguages = CFLocaleCopyPreferredLanguages();
- RetainPtr<CFArrayRef> titlesForPreferredLanguages = AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages(titles.get(), preferredLanguages.get());
+ RetainPtr<CFArrayRef> preferredLanguages = adoptCF(CFLocaleCopyPreferredLanguages());
+ RetainPtr<CFArrayRef> titlesForPreferredLanguages = adoptCF(AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages(titles.get(), preferredLanguages.get()));
CFIndex preferredTitlesCount = CFArrayGetCount(titlesForPreferredLanguages.get());
if (preferredTitlesCount) {
AVCFMetadataItemRef titleMetadata = static_cast<AVCFMetadataItemRef>(CFArrayGetValueAtIndex(titlesForPreferredLanguages.get(), 0));
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (167745 => 167746)
--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp 2014-04-24 04:46:28 UTC (rev 167746)
@@ -1757,8 +1757,9 @@
#endif
AVCFAssetImageGeneratorSetMaximumSize(m_imageGenerator.get(), CGSize(rect.size()));
- CGImageRef rawimage = AVCFAssetImageGeneratorCopyCGImageAtTime(m_imageGenerator.get(), CMTimeMakeWithSeconds(time, 600), 0, 0);
- CGImageRef image = CGImageCreateCopyWithColorSpace(rawimage, CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGImageRef> rawimage = adoptCF(AVCFAssetImageGeneratorCopyCGImageAtTime(m_imageGenerator.get(), CMTimeMakeWithSeconds(time, 600), 0, 0));
+ RetainPtr<CGImageRef> image = adoptCF(CGImageCreateCopyWithColorSpace(rawimage.get(), adoptCF(CGColorSpaceCreateDeviceRGB()).get()));
+
#if !LOG_DISABLED
double duration = monotonicallyIncreasingTime() - start;
LOG(Media, "AVFWrapper::createImageForTimeInRect(%p) - creating image took %.4f", this, narrowPrecisionToFloat(duration));
Modified: trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp (167745 => 167746)
--- trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp 2014-04-24 04:46:28 UTC (rev 167746)
@@ -209,10 +209,11 @@
}
#if !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
+
void PDFDocumentImage::createPDFDocument()
{
RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(data()->createCFData().get()));
- m_document = CGPDFDocumentCreateWithProvider(dataProvider.get());
+ m_document = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get()));
}
void PDFDocumentImage::computeBoundsForCurrentPage()
@@ -256,6 +257,7 @@
// CGPDF pages are indexed from 1.
CGContextDrawPDFPage(context->platformContext(), CGPDFDocumentGetPage(m_document.get(), 1));
}
+
#endif // !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (167745 => 167746)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm 2014-04-24 04:46:28 UTC (rev 167746)
@@ -272,9 +272,13 @@
if (descriptor)
return descriptor;
+ RetainPtr<CTFontDescriptorRef> lastResort = adoptCF(CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0));
+
+ const void* descriptors[] = { lastResort.get() };
+ RetainPtr<CFArrayRef> array = adoptCF(CFArrayCreate(kCFAllocatorDefault, descriptors, WTF_ARRAY_LENGTH(descriptors), &kCFTypeArrayCallBacks));
+
const void* keys[] = { kCTFontCascadeListAttribute };
- const void* descriptors[] = { CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0) };
- const void* values[] = { CFArrayCreate(kCFAllocatorDefault, descriptors, WTF_ARRAY_LENGTH(descriptors), &kCFTypeArrayCallBacks) };
+ const void* values[] = { array.get() };
RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
descriptor = CTFontDescriptorCreateWithAttributes(attributes.get());
Modified: trunk/Source/WebCore/platform/graphics/mac/FontMac.mm (167745 => 167746)
--- trunk/Source/WebCore/platform/graphics/mac/FontMac.mm 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/graphics/mac/FontMac.mm 2014-04-24 04:46:28 UTC (rev 167746)
@@ -543,8 +543,7 @@
bool Font::primaryFontDataIsSystemFont() const
{
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
- RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont());
- return CTFontDescriptorIsSystemUIFont(descriptor.get());
+ return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont())).get());
#else
// System fonts are hidden by having a name that begins with a period, so simply search
// for that here rather than try to keep the list up to date.
Modified: trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm (167745 => 167746)
--- trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm 2014-04-24 04:46:28 UTC (rev 167746)
@@ -372,8 +372,7 @@
UNUSED_PARAM(font);
return false;
#else
- RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(font);
- return CTFontDescriptorIsSystemUIFont(descriptor.get());
+ return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());
#endif
}
Modified: trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h (167745 => 167746)
--- trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h 2014-04-24 04:46:28 UTC (rev 167746)
@@ -320,6 +320,7 @@
size_t length = CFDataGetLength(iccProfile);
const unsigned char* systemProfile = CFDataGetBytePtr(iccProfile);
outputDeviceProfile = qcms_profile_from_memory(systemProfile, length);
+ CFRelease(iccProfile);
}
#else
// FIXME: add support for multiple monitors.
Modified: trunk/Source/WebCore/plugins/mac/PluginPackageMac.cpp (167745 => 167746)
--- trunk/Source/WebCore/plugins/mac/PluginPackageMac.cpp 2014-04-24 04:42:32 UTC (rev 167745)
+++ trunk/Source/WebCore/plugins/mac/PluginPackageMac.cpp 2014-04-24 04:46:28 UTC (rev 167746)
@@ -28,16 +28,15 @@
#include "config.h"
#include "PluginPackage.h"
-#include <wtf/RetainPtr.h>
#include "MIMETypeRegistry.h"
-#include "npruntime_impl.h"
#include "PluginDatabase.h"
#include "PluginDebug.h"
#include "WebCoreNSStringExtras.h"
+#include "npruntime_impl.h"
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/RetainPtr.h>
#include <wtf/text/CString.h>
-#include <CoreFoundation/CoreFoundation.h>
-
#define PluginNameOrDescriptionStringNumber 126
#define MIMEDescriptionStringNumber 127
#define MIMEListStringStringNumber 128
@@ -67,7 +66,7 @@
typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
-static WTF::RetainPtr<CFDictionaryRef> readPListFile(CFStringRef fileName, bool createFile, CFBundleRef bundle)
+static RetainPtr<CFDictionaryRef> readPListFile(CFStringRef fileName, bool createFile, CFBundleRef bundle)
{
if (createFile) {
BP_CreatePluginMIMETypesPreferencesFuncPtr funcPtr =
@@ -76,17 +75,15 @@
funcPtr();
}
- WTF::RetainPtr<CFDictionaryRef> map;
- WTF::RetainPtr<CFURLRef> url =
- CFURLCreateWithFileSystemPath(kCFAllocatorDefault, fileName, kCFURLPOSIXPathStyle, false);
+ RetainPtr<CFDictionaryRef> map;
+ RetainPtr<CFURLRef> url = "" fileName, kCFURLPOSIXPathStyle, false));
CFDataRef resource = 0;
SInt32 code;
if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, url.get(), &resource, 0, 0, &code))
return map;
- WTF::RetainPtr<CFPropertyListRef> propertyList =
- CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable, 0);
+ RetainPtr<CFPropertyListRef> propertyList = adoptCF(CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable, 0));
CFRelease(resource);
@@ -119,7 +116,7 @@
for (SInt16 i = 0; i < count; ++i) {
unsigned char length = *p;
- WTF::RetainPtr<CFStringRef> str = adoptCF(CFStringCreateWithPascalString(0, p, encoding));
+ RetainPtr<CFStringRef> str = adoptCF(CFStringCreateWithPascalString(0, p, encoding));
list.append(str.get());
p += 1 + length;
}
@@ -132,19 +129,19 @@
if (!load())
return false;
- WTF::RetainPtr<CFDictionaryRef> mimeDict;
+ RetainPtr<CFDictionaryRef> mimeDict;
- WTF::RetainPtr<CFTypeRef> mimeTypesFileName = CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypesFilename"));
+ RetainPtr<CFTypeRef> mimeTypesFileName = CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypesFilename"));
if (mimeTypesFileName && CFGetTypeID(mimeTypesFileName.get()) == CFStringGetTypeID()) {
- WTF::RetainPtr<CFStringRef> fileName = (CFStringRef)mimeTypesFileName.get();
- WTF::RetainPtr<CFStringRef> homeDir = adoptCF(homeDirectoryPath().createCFString());
- WTF::RetainPtr<CFStringRef> path = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%@/Library/Preferences/%@"), homeDir.get(), fileName.get()));
+ RetainPtr<CFStringRef> fileName = (CFStringRef)mimeTypesFileName.get();
+ RetainPtr<CFStringRef> homeDir = homeDirectoryPath().createCFString();
+ RetainPtr<CFStringRef> path = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%@/Library/Preferences/%@"), homeDir.get(), fileName.get()));
- WTF::RetainPtr<CFDictionaryRef> plist = readPListFile(path.get(), /*createFile*/ false, m_module);
+ RetainPtr<CFDictionaryRef> plist = readPListFile(path.get(), /*createFile*/ false, m_module);
if (plist) {
// If the plist isn't localized, have the plug-in recreate it in the preferred language.
- WTF::RetainPtr<CFStringRef> localizationName =
+ RetainPtr<CFStringRef> localizationName =
(CFStringRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginLocalizationName"));
CFLocaleRef locale = CFLocaleCopyCurrent();
if (localizationName != CFLocaleGetIdentifier(locale))
@@ -172,9 +169,9 @@
String mimeType = (CFStringRef)keys[i];
mimeType = mimeType.lower();
- WTF::RetainPtr<CFDictionaryRef> extensionsDict = (CFDictionaryRef)values[i];
+ RetainPtr<CFDictionaryRef> extensionsDict = (CFDictionaryRef)values[i];
- WTF::RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled"));
+ RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled"));
if (enabled) {
int enabledValue = 0;
if (CFNumberGetValue(enabled.get(), kCFNumberIntType, &enabledValue) && enabledValue == 0)
@@ -182,7 +179,7 @@
}
Vector<String> mimeExtensions;
- WTF::RetainPtr<CFArrayRef> extensions = (CFArrayRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginExtensions"));
+ RetainPtr<CFArrayRef> extensions = (CFArrayRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginExtensions"));
if (extensions) {
CFIndex extensionCount = CFArrayGetCount(extensions.get());
for (CFIndex i = 0; i < extensionCount; ++i) {
@@ -255,8 +252,8 @@
return true;
}
- WTF::RetainPtr<CFStringRef> path = adoptCF(m_path.createCFString());
- WTF::RetainPtr<CFURLRef> url = "" path.get(),
+ RetainPtr<CFStringRef> path = m_path.createCFString();
+ RetainPtr<CFURLRef> url = "" path.get(),
kCFURLPOSIXPathStyle, false));
m_module = CFBundleCreate(NULL, url.get());
if (!m_module || !CFBundleLoadExecutable(m_module)) {