tdf#161461 stop crashing by retaining NSString
OUStringToNSString() returns an autoreleased NSString so it needs to be retained for the life of maOfficeOnlyTypes. Change-Id: Ic3777f818b7cada8e88e97965531fc0a7f2e825c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169284 Tested-by: Jenkins Reviewed-by: Patrick Luby <guibomacdev@gmail.com>
This commit is contained in:
committed by
Patrick Luby
parent
9288a75f71
commit
dd86e0a51a
@@ -421,10 +421,17 @@ NSString* DataFlavorMapper::openOfficeToSystemFlavor(const DataFlavor& oOOFlavor
|
||||
OfficeOnlyTypes::const_iterator it = maOfficeOnlyTypes.find(oOOFlavor.MimeType);
|
||||
|
||||
if (it == maOfficeOnlyTypes.end())
|
||||
sysFlavor = maOfficeOnlyTypes[oOOFlavor.MimeType]
|
||||
= OUStringToNSString(oOOFlavor.MimeType);
|
||||
{
|
||||
// tdf#161461 stop crashing by retaining NSString
|
||||
// OUStringToNSString() returns an autoreleased NSString so it
|
||||
// needs to be retained for the life of maOfficeOnlyTypes.
|
||||
sysFlavor = maOfficeOnlyTypes[oOOFlavor.MimeType] =
|
||||
[OUStringToNSString(oOOFlavor.MimeType) retain];
|
||||
}
|
||||
else
|
||||
{
|
||||
sysFlavor = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
return sysFlavor;
|
||||
|
@@ -586,9 +586,17 @@ const NSString* DataFlavorMapper::openOfficeToSystemFlavor( const DataFlavor& oO
|
||||
OfficeOnlyTypes::const_iterator it = maOfficeOnlyTypes.find( oOOFlavor.MimeType );
|
||||
|
||||
if( it == maOfficeOnlyTypes.end() )
|
||||
sysFlavor = maOfficeOnlyTypes[ oOOFlavor.MimeType ] = OUStringToNSString( oOOFlavor.MimeType );
|
||||
{
|
||||
// tdf#161461 stop crashing by retaining NSString
|
||||
// OUStringToNSString() returns an autoreleased NSString so it
|
||||
// needs to be retained for the life of maOfficeOnlyTypes.
|
||||
sysFlavor = maOfficeOnlyTypes[oOOFlavor.MimeType] =
|
||||
[OUStringToNSString(oOOFlavor.MimeType) retain];
|
||||
}
|
||||
else
|
||||
{
|
||||
sysFlavor = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
return sysFlavor;
|
||||
|
Reference in New Issue
Block a user