Skip to content

Commit

Permalink
Fix sizes for strings to avoid random characters being appended to them
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jul 2, 2019
1 parent dcac822 commit 4f132ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace io2
if (str == "*all" || str == "*a")
{
auto _size = static_cast<size_t>(size());
string _str(readbytes(_size), 0, _size + 1);
string _str(readbytes(_size), 0, _size);
vares.push_back({lua, sol::in_place, _str});
}
else if (str == "*l")
Expand All @@ -124,7 +124,7 @@ namespace io2
else if (arg.is<lua_Integer>())
{
auto n = arg.as<lua_Integer>();
string str(readbytes(n), 0, n + 1);
string str(readbytes(n), 0, n);
if (stream.eof())
vares.push_back({lua, sol::in_place, sol::nil});
vares.push_back({lua, sol::in_place, str});
Expand Down

0 comments on commit 4f132ff

Please sign in to comment.