summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-08-06 11:55:14 +0300
committerNorbert Thiebaud <nthiebaud@gmail.com>2013-08-08 11:57:55 +0000
commit20b5932eb6f16b3674592977db56a29fb35ef6f7 (patch)
tree578bf92f598b585169e2fd15333ad5ed0bed2502
parent9b82bd95224203f62cf8d26f2af98888f915e85e (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 Reviewed-on: https://gerrit.libreoffice.org/5293 Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
-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 437f7fc5e087..743d66f409b2 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -80,7 +80,6 @@ CTLayout::CTLayout( const CTTextStyle* pTextStyle )
, mfCachedWidth( -1 )
, mfBaseAdv( 0 )
{
- CFRetain( mpTextStyle->GetStyleDict() );
}
// -----------------------------------------------------------------------
@@ -91,7 +90,6 @@ CTLayout::~CTLayout()
CFRelease( mpCTLine );
if( mpAttrString )
CFRelease( mpAttrString );
- CFRelease( mpTextStyle->GetStyleDict() );
}
// -----------------------------------------------------------------------
@@ -114,6 +112,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);