don't pass DISPLAY_OPT as a pointer to avoid NULL pointer deref
This commit is contained in:
@@ -140,7 +140,7 @@ void Bookkeeper::WriteToDisk()
|
|||||||
|
|
||||||
DISP_OPT opt;
|
DISP_OPT opt;
|
||||||
XNode *xml = CreateNode();
|
XNode *xml = CreateNode();
|
||||||
xml->SaveToFile( f, &opt );
|
xml->SaveToFile( f, opt );
|
||||||
delete xml;
|
delete xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ void SaveCatalogXml( LoadingWindow *loading_window )
|
|||||||
DISP_OPT opts;
|
DISP_OPT opts;
|
||||||
opts.stylesheet = CATALOG_XSL;
|
opts.stylesheet = CATALOG_XSL;
|
||||||
opts.write_tabs = false;
|
opts.write_tabs = false;
|
||||||
xml.SaveToFile(fn, &opts);
|
xml.SaveToFile(fn, opts);
|
||||||
|
|
||||||
LOG->Trace( "Done." );
|
LOG->Trace( "Done." );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -959,7 +959,7 @@ bool Profile::SaveStatsXmlToDir( CString sDir, bool bSignData ) const
|
|||||||
DISP_OPT opts;
|
DISP_OPT opts;
|
||||||
opts.stylesheet = STATS_XSL;
|
opts.stylesheet = STATS_XSL;
|
||||||
opts.write_tabs = false;
|
opts.write_tabs = false;
|
||||||
bool bSaved = xml->SaveToFile(fn, &opts);
|
bool bSaved = xml->SaveToFile( fn, opts );
|
||||||
|
|
||||||
SAFE_DELETE( xml );
|
SAFE_DELETE( xml );
|
||||||
|
|
||||||
|
|||||||
+24
-23
@@ -438,25 +438,25 @@ unsigned XNode::Load( const CString &xml, PARSEINFO *pi, unsigned iOffset )
|
|||||||
|
|
||||||
// Desc : convert plain xml text from parsed xml attirbute
|
// Desc : convert plain xml text from parsed xml attirbute
|
||||||
// Return : converted plain string
|
// Return : converted plain string
|
||||||
bool XNode::GetAttrXML( RageFileBasic &f, DISP_OPT *opt, const CString &sName, const CString &sValue ) const
|
bool XNode::GetAttrXML( RageFileBasic &f, DISP_OPT &opt, const CString &sName, const CString &sValue ) const
|
||||||
{
|
{
|
||||||
CString s(sValue);
|
CString s(sValue);
|
||||||
if( opt && opt->reference_value )
|
if( opt.reference_value )
|
||||||
ReplaceEntityText( s, g_mapCharsToEntities );
|
ReplaceEntityText( s, g_mapCharsToEntities );
|
||||||
return f.Write(sName + "='" + s + "' ") != -1;
|
return f.Write(sName + "='" + s + "' ") != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Desc : convert plain xml text from parsed xml node
|
// Desc : convert plain xml text from parsed xml node
|
||||||
// Return : converted plain string
|
// Return : converted plain string
|
||||||
bool XNode::GetXML( RageFileBasic &f, DISP_OPT *opt ) const
|
bool XNode::GetXML( RageFileBasic &f, DISP_OPT &opt ) const
|
||||||
{
|
{
|
||||||
// tab
|
// tab
|
||||||
if( opt && opt->newline )
|
if( opt.newline )
|
||||||
{
|
{
|
||||||
if( f.Write("\r\n") == -1 )
|
if( f.Write("\r\n") == -1 )
|
||||||
return false;
|
return false;
|
||||||
if( opt->write_tabs )
|
if( opt.write_tabs )
|
||||||
for( int i = 0 ; i < opt->tab_base ; i++)
|
for( int i = 0 ; i < opt.tab_base ; i++)
|
||||||
if( f.Write("\t") == -1 )
|
if( f.Write("\t") == -1 )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -485,9 +485,9 @@ bool XNode::GetXML( RageFileBasic &f, DISP_OPT *opt ) const
|
|||||||
if( f.Write(">") == -1 )
|
if( f.Write(">") == -1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( opt && opt->newline && !m_childs.empty() )
|
if( opt.newline && !m_childs.empty() )
|
||||||
{
|
{
|
||||||
opt->tab_base++;
|
opt.tab_base++;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOREACH_CONST_Child( this, p )
|
FOREACH_CONST_Child( this, p )
|
||||||
@@ -497,40 +497,40 @@ bool XNode::GetXML( RageFileBasic &f, DISP_OPT *opt ) const
|
|||||||
// Text Value
|
// Text Value
|
||||||
if( !m_sValue.empty() )
|
if( !m_sValue.empty() )
|
||||||
{
|
{
|
||||||
if( opt && opt->newline && !m_childs.empty() )
|
if( opt.newline && !m_childs.empty() )
|
||||||
{
|
{
|
||||||
if( opt && opt->newline )
|
if( opt.newline )
|
||||||
if( f.Write("\r\n") == -1 )
|
if( f.Write("\r\n") == -1 )
|
||||||
return false;
|
return false;
|
||||||
if( opt->write_tabs )
|
if( opt.write_tabs )
|
||||||
for( int i = 0 ; i < opt->tab_base ; i++)
|
for( int i = 0 ; i < opt.tab_base ; i++)
|
||||||
if( f.Write("\t") == -1 )
|
if( f.Write("\t") == -1 )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CString s( m_sValue );
|
CString s( m_sValue );
|
||||||
if( opt && opt->reference_value )
|
if( opt.reference_value )
|
||||||
ReplaceEntityText( s, g_mapCharsToEntities );
|
ReplaceEntityText( s, g_mapCharsToEntities );
|
||||||
if( f.Write(s) == -1 )
|
if( f.Write(s) == -1 )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// </TAG> CloseTag
|
// </TAG> CloseTag
|
||||||
if( opt && opt->newline && !m_childs.empty() )
|
if( opt.newline && !m_childs.empty() )
|
||||||
{
|
{
|
||||||
if( f.Write("\r\n") == -1 )
|
if( f.Write("\r\n") == -1 )
|
||||||
return false;
|
return false;
|
||||||
if( opt->write_tabs )
|
if( opt.write_tabs )
|
||||||
for( int i = 0 ; i < opt->tab_base-1 ; i++)
|
for( int i = 0 ; i < opt.tab_base-1 ; i++)
|
||||||
if( f.Write("\t") == -1 )
|
if( f.Write("\t") == -1 )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( f.Write("</" + m_sName + ">") == -1 )
|
if( f.Write("</" + m_sName + ">") == -1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( opt && opt->newline )
|
if( opt.newline )
|
||||||
{
|
{
|
||||||
if( !m_childs.empty() )
|
if( !m_childs.empty() )
|
||||||
opt->tab_base--;
|
opt.tab_base--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -541,7 +541,8 @@ bool XNode::GetXML( RageFileBasic &f, DISP_OPT *opt ) const
|
|||||||
CString XNode::GetXML() const
|
CString XNode::GetXML() const
|
||||||
{
|
{
|
||||||
RageFileObjMem f;
|
RageFileObjMem f;
|
||||||
GetXML( f, NULL );
|
DISP_OPT opt;
|
||||||
|
GetXML( f, opt );
|
||||||
return f.GetString();
|
return f.GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,11 +698,11 @@ error:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const
|
bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT &opt ) const
|
||||||
{
|
{
|
||||||
f.PutLine( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" );
|
f.PutLine( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" );
|
||||||
if( !opt->stylesheet.empty() )
|
if( !opt.stylesheet.empty() )
|
||||||
f.PutLine( "<?xml-stylesheet type=\"text/xsl\" href=\"" + opt->stylesheet + "\"?>" );
|
f.PutLine( "<?xml-stylesheet type=\"text/xsl\" href=\"" + opt.stylesheet + "\"?>" );
|
||||||
if( !this->GetXML(f, opt) )
|
if( !this->GetXML(f, opt) )
|
||||||
return false;
|
return false;
|
||||||
if( f.Flush() == -1 )
|
if( f.Flush() == -1 )
|
||||||
@@ -709,7 +710,7 @@ bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XNode::SaveToFile( const CString &sFile, DISP_OPT *opt ) const
|
bool XNode::SaveToFile( const CString &sFile, DISP_OPT &opt ) const
|
||||||
{
|
{
|
||||||
RageFile f;
|
RageFile f;
|
||||||
if( !f.Open(sFile, RageFile::WRITE) )
|
if( !f.Open(sFile, RageFile::WRITE) )
|
||||||
|
|||||||
@@ -102,14 +102,14 @@ struct XNode
|
|||||||
// Load/Save XML
|
// Load/Save XML
|
||||||
unsigned Load( const CString &sXml, PARSEINFO *pi, unsigned iOffset = 0 );
|
unsigned Load( const CString &sXml, PARSEINFO *pi, unsigned iOffset = 0 );
|
||||||
unsigned LoadAttributes( const CString &sAttrs, PARSEINFO *pi, unsigned iOffset );
|
unsigned LoadAttributes( const CString &sAttrs, PARSEINFO *pi, unsigned iOffset );
|
||||||
bool GetXML( RageFileBasic &f, DISP_OPT *opt ) const;
|
bool GetXML( RageFileBasic &f, DISP_OPT &opt ) const;
|
||||||
bool GetAttrXML( RageFileBasic &f, DISP_OPT *opt, const CString &sName, const CString &sValue ) const;
|
bool GetAttrXML( RageFileBasic &f, DISP_OPT &opt, const CString &sName, const CString &sValue ) const;
|
||||||
CString GetXML() const;
|
CString GetXML() const;
|
||||||
|
|
||||||
bool LoadFromFile( const CString &sFile );
|
bool LoadFromFile( const CString &sFile );
|
||||||
bool LoadFromFile( RageFileBasic &f );
|
bool LoadFromFile( RageFileBasic &f );
|
||||||
bool SaveToFile( const CString &sFile, DISP_OPT *opt ) const;
|
bool SaveToFile( const CString &sFile, DISP_OPT &opt ) const;
|
||||||
bool SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const;
|
bool SaveToFile( RageFileBasic &f, DISP_OPT &opt ) const;
|
||||||
|
|
||||||
// in own attribute list
|
// in own attribute list
|
||||||
const CString *GetAttr( const CString &sAttrName ) const;
|
const CString *GetAttr( const CString &sAttrName ) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user