summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-08-06 11:55:14 +0300
committerTor Lillqvist <tml@iki.fi>2013-08-06 13:18:53 +0300
commita321be22907c47e2e378c494f0de9f3f68af5167 (patch)
treef9109d084209bf73f4e158b4b27be248a2272466
parent637d645a34201fe7b7f4890ecafd7df0f7c105af (diff)
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
-rw-r--r--vcl/coretext/ctlayout.cxx3
1 files changed, 1 insertions, 2 deletions
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 935dc94242d3..41e346072730 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -81,7 +81,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
, mfCachedWidth( -1 )
, mfBaseAdv( 0 )
{
- CFRetain( mpTextStyle->GetStyleDict() );
}
// -----------------------------------------------------------------------
@@ -92,7 +91,6 @@ CTLayout::~CTLayout()
CFRelease( mpCTLine );
if( mpAttrString )
CFRelease( mpAttrString );
- CFRelease( mpTextStyle->GetStyleDict() );
}
// -----------------------------------------------------------------------
@@ -115,6 +113,7 @@ bool CTLayout::LayoutText( ImplLayoutArgs& rArgs )
// create the CoreText line layout
CFStringRef aCFText = CFStringCreateWithCharactersNoCopy( NULL, rArgs.mpStr + mnMinCharPos, mnCharCount, kCFAllocatorNull );
+ // CFAttributedStringCreate copies the attribues parameter
mpAttrString = CFAttributedStringCreate( NULL, aCFText, mpTextStyle->GetStyleDict() );
mpCTLine = CTLineCreateWithAttributedString( mpAttrString );
CFRelease( aCFText);