Changeset 167746 in webkit


Ignore:
Timestamp:
Apr 23, 2014 9:46:28 PM (10 years ago)
Author:
Darin Adler
Message:

[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.

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167744 r167746  
     12014-04-23  Darin Adler  <darin@apple.com>
     2
     3        [Cocoa] fix CF leaks found by code inspection
     4        https://bugs.webkit.org/show_bug.cgi?id=132106
     5
     6        Reviewed by Andreas Kling.
     7
     8        * page/CaptionUserPreferencesMediaAF.cpp:
     9        (WebCore::trackDisplayName): Added a missing adoptCF.
     10
     11        * platform/Language.cpp:
     12        (WebCore::displayNameForLanguageLocale): Added a missing adoptCF.
     13
     14        * platform/graphics/FontPlatformData.cpp:
     15        (WebCore::FontPlatformData::openTypeTable): Added a missing adoptCF.
     16
     17        * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
     18        (WebCore::InbandTextTrackPrivateAVCF::label): Added two missing adoptCF.
     19
     20        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
     21        (WebCore::AVFWrapper::createImageForTimeInRect): Added two missing adoptCF.
     22
     23        * platform/graphics/cg/PDFDocumentImage.cpp:
     24        (WebCore::PDFDocumentImage::createPDFDocument): Added missing adoptCF.
     25
     26        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
     27        (WebCore::cascadeToLastResortFontDescriptor): Added two missing adoptCF.
     28
     29        * platform/graphics/mac/FontMac.mm:
     30        (WebCore::Font::primaryFontDataIsSystemFont): Added missing adoptCF.
     31
     32        * platform/graphics/mac/SimpleFontDataMac.mm:
     33        (WebCore::hasCustomTracking): Added missing adoptCF.
     34
     35        * platform/image-decoders/ImageDecoder.h:
     36        (WebCore::ImageDecoder::qcmsOutputDeviceProfile): Added CFRelease.
     37
     38        * plugins/mac/PluginPackageMac.cpp:
     39        (WebCore::readPListFile): Added two missing adoptCF.
     40
    1412014-04-23  Ryosuke Niwa  <rniwa@webkit.org>
    242
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r165607 r167746  
    609609        }
    610610    } else {
    611         String languageAndLocale = CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, trackLanguageIdentifier.createCFString().get());
     611        String languageAndLocale = adoptCF(CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, trackLanguageIdentifier.createCFString().get())).get();
    612612        if (!languageAndLocale.isEmpty())
    613613            displayName.append(languageAndLocale);
  • trunk/Source/WebCore/platform/Language.cpp

    r165607 r167746  
    149149{
    150150#if USE(CF) && !PLATFORM(WIN)
    151     if (!localeName.isNull() && !localeName.isEmpty()) {
    152         RetainPtr<CFLocaleRef> currentLocale = adoptCF(CFLocaleCopyCurrent());
    153         return CFLocaleCopyDisplayNameForPropertyValue(currentLocale.get(), kCFLocaleIdentifier, localeName.createCFString().get());
    154     }
     151    if (!localeName.isEmpty())
     152        return adoptCF(CFLocaleCopyDisplayNameForPropertyValue(adoptCF(CFLocaleCopyCurrent()).get(), kCFLocaleIdentifier, localeName.createCFString().get())).get();
    155153#endif
    156154    return localeName;
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp

    r166633 r167746  
    178178PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
    179179{
    180     if (CFDataRef data = CGFontCopyTableForTag(cgFont(), table))
    181         return SharedBuffer::wrapCFData(data);
     180    if (RetainPtr<CFDataRef> data = adoptCF(CGFontCopyTableForTag(cgFont(), table)))
     181        return SharedBuffer::wrapCFData(data.get());
    182182   
    183183    return nullptr;
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp

    r165676 r167746  
    149149
    150150    // If possible, return a title in one of the user's preferred languages.
    151     RetainPtr<CFArrayRef> preferredLanguages = CFLocaleCopyPreferredLanguages();
    152     RetainPtr<CFArrayRef> titlesForPreferredLanguages = AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages(titles.get(), preferredLanguages.get());
     151    RetainPtr<CFArrayRef> preferredLanguages = adoptCF(CFLocaleCopyPreferredLanguages());
     152    RetainPtr<CFArrayRef> titlesForPreferredLanguages = adoptCF(AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages(titles.get(), preferredLanguages.get()));
    153153    CFIndex preferredTitlesCount = CFArrayGetCount(titlesForPreferredLanguages.get());
    154154    if (preferredTitlesCount) {
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r167632 r167746  
    17581758
    17591759    AVCFAssetImageGeneratorSetMaximumSize(m_imageGenerator.get(), CGSize(rect.size()));
    1760     CGImageRef rawimage = AVCFAssetImageGeneratorCopyCGImageAtTime(m_imageGenerator.get(), CMTimeMakeWithSeconds(time, 600), 0, 0);
    1761     CGImageRef image = CGImageCreateCopyWithColorSpace(rawimage,  CGColorSpaceCreateDeviceRGB());
     1760    RetainPtr<CGImageRef> rawimage = adoptCF(AVCFAssetImageGeneratorCopyCGImageAtTime(m_imageGenerator.get(), CMTimeMakeWithSeconds(time, 600), 0, 0));
     1761    RetainPtr<CGImageRef> image = adoptCF(CGImageCreateCopyWithColorSpace(rawimage.get(), adoptCF(CGColorSpaceCreateDeviceRGB()).get()));
     1762
    17621763#if !LOG_DISABLED
    17631764    double duration = monotonicallyIncreasingTime() - start;
  • trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp

    r166582 r167746  
    210210
    211211#if !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
     212
    212213void PDFDocumentImage::createPDFDocument()
    213214{
    214215    RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(data()->createCFData().get()));
    215     m_document = CGPDFDocumentCreateWithProvider(dataProvider.get());
     216    m_document = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get()));
    216217}
    217218
     
    257258    CGContextDrawPDFPage(context->platformContext(), CGPDFDocumentGetPage(m_document.get(), 1));
    258259}
     260
    259261#endif // !USE(PDFKIT_FOR_PDFDOCUMENTIMAGE)
    260262
  • trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm

    r166603 r167746  
    273273        return descriptor;
    274274
     275    RetainPtr<CTFontDescriptorRef> lastResort = adoptCF(CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0));
     276
     277    const void* descriptors[] = { lastResort.get() };
     278    RetainPtr<CFArrayRef> array = adoptCF(CFArrayCreate(kCFAllocatorDefault, descriptors, WTF_ARRAY_LENGTH(descriptors), &kCFTypeArrayCallBacks));
     279
    275280    const void* keys[] = { kCTFontCascadeListAttribute };
    276     const void* descriptors[] = { CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0) };
    277     const void* values[] = { CFArrayCreate(kCFAllocatorDefault, descriptors, WTF_ARRAY_LENGTH(descriptors), &kCFTypeArrayCallBacks) };
     281    const void* values[] = { array.get() };
    278282    RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
    279283
  • trunk/Source/WebCore/platform/graphics/mac/FontMac.mm

    r167724 r167746  
    544544{
    545545#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
    546     RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont());
    547     return CTFontDescriptorIsSystemUIFont(descriptor.get());
     546    return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont())).get());
    548547#else
    549548    // System fonts are hidden by having a name that begins with a period, so simply search
  • trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r167683 r167746  
    373373    return false;
    374374#else
    375     RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(font);
    376     return CTFontDescriptorIsSystemUIFont(descriptor.get());
     375    return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());
    377376#endif
    378377}
  • trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h

    r165676 r167746  
    321321                    const unsigned char* systemProfile = CFDataGetBytePtr(iccProfile);
    322322                    outputDeviceProfile = qcms_profile_from_memory(systemProfile, length);
     323                    CFRelease(iccProfile);
    323324                }
    324325#else
  • trunk/Source/WebCore/plugins/mac/PluginPackageMac.cpp

    r165676 r167746  
    2929#include "PluginPackage.h"
    3030
    31 #include <wtf/RetainPtr.h>
    3231#include "MIMETypeRegistry.h"
    33 #include "npruntime_impl.h"
    3432#include "PluginDatabase.h"
    3533#include "PluginDebug.h"
    3634#include "WebCoreNSStringExtras.h"
     35#include "npruntime_impl.h"
     36#include <CoreFoundation/CoreFoundation.h>
     37#include <wtf/RetainPtr.h>
    3738#include <wtf/text/CString.h>
    38 
    39 #include <CoreFoundation/CoreFoundation.h>
    4039
    4140#define PluginNameOrDescriptionStringNumber     126
     
    6867typedef void (*BP_CreatePluginMIMETypesPreferencesFuncPtr)(void);
    6968
    70 static WTF::RetainPtr<CFDictionaryRef> readPListFile(CFStringRef fileName, bool createFile, CFBundleRef bundle)
     69static RetainPtr<CFDictionaryRef> readPListFile(CFStringRef fileName, bool createFile, CFBundleRef bundle)
    7170{
    7271    if (createFile) {
     
    7776    }
    7877
    79     WTF::RetainPtr<CFDictionaryRef> map;
    80     WTF::RetainPtr<CFURLRef> url =
    81         CFURLCreateWithFileSystemPath(kCFAllocatorDefault, fileName, kCFURLPOSIXPathStyle, false);
     78    RetainPtr<CFDictionaryRef> map;
     79    RetainPtr<CFURLRef> url = adoptCF(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, fileName, kCFURLPOSIXPathStyle, false));
    8280
    8381    CFDataRef resource = 0;
     
    8684        return map;
    8785
    88     WTF::RetainPtr<CFPropertyListRef> propertyList =
    89             CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable, 0);
     86    RetainPtr<CFPropertyListRef> propertyList = adoptCF(CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable, 0));
    9087
    9188    CFRelease(resource);
     
    120117    for (SInt16 i = 0; i < count; ++i) {
    121118        unsigned char length = *p;
    122         WTF::RetainPtr<CFStringRef> str = adoptCF(CFStringCreateWithPascalString(0, p, encoding));
     119        RetainPtr<CFStringRef> str = adoptCF(CFStringCreateWithPascalString(0, p, encoding));
    123120        list.append(str.get());
    124121        p += 1 + length;
     
    133130        return false;
    134131
    135     WTF::RetainPtr<CFDictionaryRef> mimeDict;
    136 
    137     WTF::RetainPtr<CFTypeRef> mimeTypesFileName = CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypesFilename"));
     132    RetainPtr<CFDictionaryRef> mimeDict;
     133
     134    RetainPtr<CFTypeRef> mimeTypesFileName = CFBundleGetValueForInfoDictionaryKey(m_module, CFSTR("WebPluginMIMETypesFilename"));
    138135    if (mimeTypesFileName && CFGetTypeID(mimeTypesFileName.get()) == CFStringGetTypeID()) {
    139136
    140         WTF::RetainPtr<CFStringRef> fileName = (CFStringRef)mimeTypesFileName.get();
    141         WTF::RetainPtr<CFStringRef> homeDir = adoptCF(homeDirectoryPath().createCFString());
    142         WTF::RetainPtr<CFStringRef> path = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%@/Library/Preferences/%@"), homeDir.get(), fileName.get()));
    143 
    144         WTF::RetainPtr<CFDictionaryRef> plist = readPListFile(path.get(), /*createFile*/ false, m_module);
     137        RetainPtr<CFStringRef> fileName = (CFStringRef)mimeTypesFileName.get();
     138        RetainPtr<CFStringRef> homeDir = homeDirectoryPath().createCFString();
     139        RetainPtr<CFStringRef> path = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%@/Library/Preferences/%@"), homeDir.get(), fileName.get()));
     140
     141        RetainPtr<CFDictionaryRef> plist = readPListFile(path.get(), /*createFile*/ false, m_module);
    145142        if (plist) {
    146143            // If the plist isn't localized, have the plug-in recreate it in the preferred language.
    147             WTF::RetainPtr<CFStringRef> localizationName =
     144            RetainPtr<CFStringRef> localizationName =
    148145                (CFStringRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginLocalizationName"));
    149146            CFLocaleRef locale = CFLocaleCopyCurrent();
     
    173170            mimeType = mimeType.lower();
    174171
    175             WTF::RetainPtr<CFDictionaryRef> extensionsDict = (CFDictionaryRef)values[i];
    176 
    177             WTF::RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled"));
     172            RetainPtr<CFDictionaryRef> extensionsDict = (CFDictionaryRef)values[i];
     173
     174            RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled"));
    178175            if (enabled) {
    179176                int enabledValue = 0;
     
    183180
    184181            Vector<String> mimeExtensions;
    185             WTF::RetainPtr<CFArrayRef> extensions = (CFArrayRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginExtensions"));
     182            RetainPtr<CFArrayRef> extensions = (CFArrayRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginExtensions"));
    186183            if (extensions) {
    187184                CFIndex extensionCount = CFArrayGetCount(extensions.get());
     
    256253    }
    257254
    258     WTF::RetainPtr<CFStringRef> path = adoptCF(m_path.createCFString());
    259     WTF::RetainPtr<CFURLRef> url = adoptCF(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path.get(),
     255    RetainPtr<CFStringRef> path = m_path.createCFString();
     256    RetainPtr<CFURLRef> url = adoptCF(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path.get(),
    260257                                                                        kCFURLPOSIXPathStyle, false));
    261258    m_module = CFBundleCreate(NULL, url.get());
Note: See TracChangeset for help on using the changeset viewer.