Skip to content

Commit d00065b

Browse files
author
Pavel Kovalenko
committed
Fix potential stack overflow in editor::environment::weathers::manager::load.
1 parent 0f8835f commit d00065b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/xrEngine/editor_environment_weathers_manager.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void manager::load ()
5959
typedef xr_vector<LPSTR> file_list_type;
6060
file_list_type* file_list = FS.file_list_open("$game_weathers$","");
6161
VERIFY (file_list);
62-
62+
xr_string id;
6363
file_list_type::const_iterator i = file_list->begin();
6464
file_list_type::const_iterator e = file_list->end();
6565
for ( ; i != e; ++i) {
@@ -79,11 +79,9 @@ void manager::load ()
7979
if ((*i)[length - 1] != 'x')
8080
continue;
8181

82-
u32 new_length = length - 4;
83-
LPSTR identifier = (LPSTR)_alloca((new_length + 1)*sizeof(char));
84-
Memory.mem_copy (identifier, *i, new_length*sizeof(char));
85-
identifier[new_length] = 0;
86-
weather* object = xr_new<weather>(&m_manager, identifier);
82+
id = *i;
83+
id[length-4] = 0;
84+
weather* object = xr_new<weather>(&m_manager, id.c_str());
8785
object->load ();
8886
object->fill (m_collection);
8987
m_weathers.push_back (object);

0 commit comments

Comments
 (0)