diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-02-13 11:50:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-02-13 11:52:57 +0000 |
commit | 62fb1958f6ac4d238e98cfb6b497f5990615450f (patch) | |
tree | b774ed4d6d6e5e62798b335f0b15a2dfcea07aa6 /helpcompiler | |
parent | 2bdea3b8cf15f3529348813fd253dfdbb8ff5556 (diff) |
make building help not crash
a) subStr is not ours to delete, belongs to the OString
b) and anyway subStr points to the buffer of the out-of-scope temporary OString
Change-Id: I1689c6626c52ae9d94e0cfa5de4235be3c1f3262
Diffstat (limited to 'helpcompiler')
-rw-r--r-- | helpcompiler/source/BasCodeTagger.cxx | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/helpcompiler/source/BasCodeTagger.cxx b/helpcompiler/source/BasCodeTagger.cxx index 585291288342..a984eb742962 100644 --- a/helpcompiler/source/BasCodeTagger.cxx +++ b/helpcompiler/source/BasCodeTagger.cxx @@ -143,17 +143,14 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph ) m_Highlighter.notifyChange ( 0, 0, &strLine, 1 ); HighlightPortions portions; m_Highlighter.getHighlightPortions( 0, strLine, portions ); - xmlChar* subStr; - xmlChar* typeStr; - xmlNodePtr text; for ( size_t i=0; i<portions.size(); i++ ) { HighlightPortion& r = portions[i]; - subStr = (xmlChar*) OUStringToOString( strLine.copy( r.nBegin, r.nEnd-r.nBegin ), RTL_TEXTENCODING_UTF8 ).getStr(); - text = xmlNewText( subStr ); + OString sToken(OUStringToOString(strLine.copy(r.nBegin, r.nEnd-r.nBegin), RTL_TEXTENCODING_UTF8)); + xmlNodePtr text = xmlNewText((const xmlChar*)sToken.getStr()); if ( r.tokenType != TT_WHITESPACE ) { - typeStr = getTypeString( r.tokenType ); + xmlChar* typeStr = getTypeString( r.tokenType ); curNode = xmlNewTextChild( paragraph, 0, (xmlChar*)"item", 0 ); xmlNewProp( curNode, (xmlChar*)"type", typeStr ); xmlAddChild( curNode, text ); @@ -161,7 +158,6 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph ) } else xmlAddChild( paragraph, text ); - xmlFree( subStr ); } xmlFree( codeSnippet ); } |