Skip to content

Commit 373d997

Browse files
committed
Do not pass a pointer to an temporary IReader in CInifile
Address of an rvalue may not be taken.
1 parent 960761c commit 373d997

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

src/xrGame/GameObject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ BOOL CGameObject::net_Spawn(CSE_Abstract* DC)
491491
{
492492
#pragma warning(push)
493493
#pragma warning(disable : 4238)
494-
m_ini_file = new CInifile(
495-
&IReader((void*)(*(O->m_ini_string)), O->m_ini_string.size()), FS.get_path("$game_config$")->m_Path);
494+
IReader reader((void*)(*(O->m_ini_string)), O->m_ini_string.size());
495+
m_ini_file = new CInifile(&reader, FS.get_path("$game_config$")->m_Path);
496496
#pragma warning(pop)
497497
}
498498

src/xrGame/alife_object.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ void CSE_ALifeObject::spawn_supplies(LPCSTR ini_string)
2424

2525
#pragma warning(push)
2626
#pragma warning(disable : 4238)
27-
CInifile ini(&IReader((void*)ini_string, xr_strlen(ini_string)), FS.get_path("$game_config$")->m_Path);
27+
IReader reader((void*)ini_string, xr_strlen(ini_string));
28+
CInifile ini(&reader, FS.get_path("$game_config$")->m_Path);
2829
#pragma warning(pop)
2930

3031
// Alundaio: This will spawn a single random section listed in [spawn_loadout]

src/xrGame/alife_trader_abstract.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ void CSE_ALifeTraderAbstract::spawn_supplies()
4949
{
5050
#pragma warning(push)
5151
#pragma warning(disable : 4238)
52-
CInifile ini(&IReader((void*)(*dynamic_object->m_ini_string), xr_strlen(dynamic_object->m_ini_string)),
53-
FS.get_path("$game_config$")->m_Path);
52+
IReader reader((void*)(*dynamic_object->m_ini_string), xr_strlen(dynamic_object->m_ini_string));
53+
CInifile ini(&reader, FS.get_path("$game_config$")->m_Path);
5454
#pragma warning(pop)
5555

5656
if (ini.section_exist("dont_spawn_character_supplies"))

src/xrServerEntities/script_ini_file_script.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ bool r_line(CScriptIniFile* self, LPCSTR S, int L, luabind::string& N, luabind::
3737
#pragma warning(disable : 4238)
3838
CScriptIniFile* create_ini_file(LPCSTR ini_string)
3939
{
40-
return ((CScriptIniFile*)new CInifile(
41-
&IReader((void*)ini_string, xr_strlen(ini_string)), FS.get_path("$game_config$")->m_Path));
40+
IReader reader((void*)ini_string, xr_strlen(ini_string));
41+
return ((CScriptIniFile*)new CInifile(&reader, FS.get_path("$game_config$")->m_Path));
4242
}
4343
#pragma warning(pop)
4444

src/xrServerEntities/xrServer_Object_Base.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ IServerEntityShape* CSE_Abstract::shape() { return (nullptr); }
157157
CSE_Motion* CSE_Abstract::motion() { return (nullptr); }
158158
CInifile& CSE_Abstract::spawn_ini()
159159
{
160-
if (!m_ini_file)
160+
if (!m_ini_file) {
161161
#pragma warning(push)
162162
#pragma warning(disable : 4238)
163163
// XXX: what a casting mess.. Do we need to use shared_str for m_ini_string?
164-
m_ini_file =
165-
new CInifile(&IReader((void*)(*(m_ini_string)), m_ini_string.size()), FS.get_path(_game_config_)->m_Path);
164+
IReader reader((void*)(*(m_ini_string)), m_ini_string.size());
165+
m_ini_file = new CInifile(&reader, FS.get_path(_game_config_)->m_Path);
166166
#pragma warning(pop)
167+
}
167168
return (*m_ini_file);
168169
}
169170

0 commit comments

Comments
 (0)