diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-06-06 16:35:52 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-06-06 16:55:32 +0200 |
commit | c0129c7199b1662caf010fa556b2973196ce7b07 (patch) | |
tree | 5385ff3a9648c54874c3ac5b30eefb8e9fe9d147 /sw/source | |
parent | 9bf6c83367cedb7be81bf67f30d2147d26c7a8c3 (diff) |
bnc#382137 DocxAttributeOutput: don't store address of local variable
AttributeOutputBase::TextField() passes the address of its local
variable to WriteExpand(), and DocxAttributeOutput::WriteField_Impl()
stored this. When it was to be used, the variable already went out of
scope, resulting in a crash. Given that SwField is an abstract base
class, the easiest way is to just copy the field and manually delete it
when it's no longer needed.
Change-Id: I9d1fe2485277f1ac21a576d7ff0d05003f0ac8a1
(cherry picked from commit 92f328fb5eef672d379ed0b712b025eb80622d5a)
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 549ed5266fbb..66c003ea2898 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -564,6 +564,8 @@ void DocxAttributeOutput::EndRun() // Unknown fields sould be removed too if ( !pIt->bClose || ( pIt->eType == ww::eUNKNOWN ) ) { + if (pIt->pField) + delete pIt->pField; pIt = m_Fields.erase( pIt ); continue; } @@ -598,6 +600,8 @@ void DocxAttributeOutput::EndRun() // Remove the field if no end needs to be written if ( !pIt->bClose ) { + if (pIt->pField) + delete pIt->pField; pIt = m_Fields.erase( pIt ); continue; } @@ -646,6 +650,8 @@ void DocxAttributeOutput::EndRun() while ( m_Fields.begin() != m_Fields.end() ) { EndField_Impl( m_Fields.front( ) ); + if (m_Fields.front().pField) + delete m_Fields.front().pField; m_Fields.erase( m_Fields.begin( ) ); } @@ -3829,7 +3835,8 @@ void DocxAttributeOutput::WriteExpand( const SwField* pFld ) void DocxAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField eType, const String& rFldCmd, sal_uInt8 nMode ) { struct FieldInfos infos; - infos.pField = pFld; + if (pFld) + infos.pField = pFld->CopyField(); infos.sCmd = rFldCmd; infos.eType = eType; infos.bClose = WRITEFIELD_CLOSE & nMode; |