Skip to content

Commit 4f132ff

Browse files
committed
Fix sizes for strings to avoid random characters being appended to them
1 parent dcac822 commit 4f132ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace io2
113113
if (str == "*all" || str == "*a")
114114
{
115115
auto _size = static_cast<size_t>(size());
116-
string _str(readbytes(_size), 0, _size + 1);
116+
string _str(readbytes(_size), 0, _size);
117117
vares.push_back({lua, sol::in_place, _str});
118118
}
119119
else if (str == "*l")
@@ -124,7 +124,7 @@ namespace io2
124124
else if (arg.is<lua_Integer>())
125125
{
126126
auto n = arg.as<lua_Integer>();
127-
string str(readbytes(n), 0, n + 1);
127+
string str(readbytes(n), 0, n);
128128
if (stream.eof())
129129
vares.push_back({lua, sol::in_place, sol::nil});
130130
vares.push_back({lua, sol::in_place, str});

0 commit comments

Comments
 (0)