mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix string truncation bug in scripting api
This commit is contained in:
parent
58bf5c5008
commit
a1217af4c6
1 changed files with 6 additions and 2 deletions
|
|
@ -332,7 +332,11 @@ error_rs:
|
|||
lua_pushnumber(L, ret);
|
||||
if (buffer != NULL)
|
||||
{
|
||||
lua_pushstring(L, ret > 0 ? buffer : "");
|
||||
if (ret > 0) {
|
||||
lua_pushlstring(L, buffer, ret);
|
||||
} else {
|
||||
lua_pushstring(L, "");
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
else
|
||||
|
|
@ -400,7 +404,7 @@ static int read_line(lua_State *L)
|
|||
|
||||
error_rl:
|
||||
lua_pushnumber(L, ret);
|
||||
lua_pushstring(L, linebuf);
|
||||
lua_pushlstring(L, linebuf, ret);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue