Skip to content

Commit

Permalink
Fix potential stack overflow in editor::environment::weathers::manage…
Browse files Browse the repository at this point in the history
…r::load.
  • Loading branch information
Pavel Kovalenko committed Oct 8, 2014
1 parent 0f8835f commit d00065b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/xrEngine/editor_environment_weathers_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void manager::load ()
typedef xr_vector<LPSTR> file_list_type;
file_list_type* file_list = FS.file_list_open("$game_weathers$","");
VERIFY (file_list);
xr_string id;
file_list_type::const_iterator i = file_list->begin();
file_list_type::const_iterator e = file_list->end();
for ( ; i != e; ++i) {
Expand All @@ -79,11 +79,9 @@ void manager::load ()
if ((*i)[length - 1] != 'x')
continue;

u32 new_length = length - 4;
LPSTR identifier = (LPSTR)_alloca((new_length + 1)*sizeof(char));
Memory.mem_copy (identifier, *i, new_length*sizeof(char));
identifier[new_length] = 0;
weather* object = xr_new<weather>(&m_manager, identifier);
id = *i;
id[length-4] = 0;
weather* object = xr_new<weather>(&m_manager, id.c_str());
object->load ();
object->fill (m_collection);
m_weathers.push_back (object);
Expand Down

0 comments on commit d00065b

Please sign in to comment.