Skip to content

Commit

Permalink
xrCore: fix undefined behavior (method return stack-allocated object)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Dec 4, 2018
1 parent fa29be7 commit e1c4369
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,10 +1559,8 @@ CLocatorAPI::files_it CLocatorAPI::file_find_it(pcstr fname)
VERIFY(xr_strlen(fname) * sizeof(char) < sizeof(file_name));
xr_strcpy(file_name, sizeof file_name, fname);
desc_f.name = file_name;
// desc_f.name = xr_strlwr(xr_strdup(fname));

This comment has been minimized.

Copy link
@Kaffeine

Kaffeine Dec 4, 2018

Member

The patch makes no difference on the compiled code. It is fine to return a "stack-allocated object" by value (it could be wrong to return a pointer or a reference to such object).

files_it I = m_files.find(desc_f);
// xr_free (desc_f.name);
return I;

return m_files.find(desc_f);
}

bool CLocatorAPI::dir_delete(pcstr initial, pcstr nm, bool remove_files)
Expand Down

0 comments on commit e1c4369

Please sign in to comment.