Kaydet (Commit) a321be22 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

fdo#67660: Fix memory mismanagement crash

The CTLayout constructor called CFRetain() on the associated
CTTextStyle's attribute directory (a CFMutableDictionaryRef) and the
destructor then called CFRelease() on it, even if there was no
guarantee it was still the same CTTextStyle. And in the scenario that
caused this crash, AquaSalGraphics::SetFont() had in fact deleted the
original CTTextStyle and created a new one.

It seems to me that these CFRetain() and CFRelease() calls are not
necessary.

Change-Id: I18e03965dd05d450955353f8c48f111c19a069e3
üst 637d645a
...@@ -81,7 +81,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle ) ...@@ -81,7 +81,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
, mfCachedWidth( -1 ) , mfCachedWidth( -1 )
, mfBaseAdv( 0 ) , mfBaseAdv( 0 )
{ {
CFRetain( mpTextStyle->GetStyleDict() );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -92,7 +91,6 @@ CTLayout::~CTLayout() ...@@ -92,7 +91,6 @@ CTLayout::~CTLayout()
CFRelease( mpCTLine ); CFRelease( mpCTLine );
if( mpAttrString ) if( mpAttrString )
CFRelease( mpAttrString ); CFRelease( mpAttrString );
CFRelease( mpTextStyle->GetStyleDict() );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -115,6 +113,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs ) ...@@ -115,6 +113,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
// create the CoreText line layout // create the CoreText line layout
CFStringRef aCFText = CFStringCreateWithCharactersNoCopy( NULL, rArgs.mpStr + mnMinCharPos, mnCharCount, kCFAllocatorNull ); CFStringRef aCFText = CFStringCreateWithCharactersNoCopy( NULL, rArgs.mpStr + mnMinCharPos, mnCharCount, kCFAllocatorNull );
// CFAttributedStringCreate copies the attribues parameter
mpAttrString = CFAttributedStringCreate( NULL, aCFText, mpTextStyle->GetStyleDict() ); mpAttrString = CFAttributedStringCreate( NULL, aCFText, mpTextStyle->GetStyleDict() );
mpCTLine = CTLineCreateWithAttributedString( mpAttrString ); mpCTLine = CTLineCreateWithAttributedString( mpAttrString );
CFRelease( aCFText); CFRelease( aCFText);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment