From c0987f2b32dd86de874456d3047e79b88abaa05f Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 24 Nov 2016 11:59:11 +0000 Subject: [PATCH] Fixed a false positive in ASAN in a recent bug fix commit to OSXTypeface --- modules/juce_graphics/native/juce_mac_Fonts.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 95b02d9c35..ef078ee9d8 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -541,11 +541,15 @@ public: fontHeightToPointsFactor (1.0f), renderingTransform (CGAffineTransformIdentity), isMemoryFont (true), + dataCopy (data, dataSize), attributedStringAtts (nullptr), ascent (0.0f), unitsToHeightScaleFactor (0.0f) { - CFDataRef cfData = CFDataCreate (kCFAllocatorDefault, (const UInt8*) data, (CFIndex) dataSize); + // We can't use CFDataCreate here as this triggers a false positive in ASAN + // so copy the data manually and use CFDataCreateWithBytesNoCopy + CFDataRef cfData = CFDataCreateWithBytesNoCopy (kCFAllocatorDefault, (const UInt8*) dataCopy.getData(), + (CFIndex) dataCopy.getSize(), kCFAllocatorNull); CGDataProviderRef provider = CGDataProviderCreateWithCFData (cfData); CFRelease (cfData); @@ -709,6 +713,7 @@ public: bool isMemoryFont; private: + MemoryBlock dataCopy; CFDictionaryRef attributedStringAtts; float ascent, unitsToHeightScaleFactor; AffineTransform pathTransform;