Skip to content

Commit d364b04

Browse files
committed
lua: remove luajit pushlstring workaround
81ee6f5 ("lua: push correct length back through ScFlowvarGet, work around valgrind warning") added a workaround for valgrind warnings in pushing a string buffer into the lua state. This is no longer needed as tested with both address sanitizer and valgrind. (cherry picked from commit 52fd61d)
1 parent 88077ad commit d364b04

1 file changed

Lines changed: 1 addition & 16 deletions

File tree

src/util-lua.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,22 +318,7 @@ void LuaPrintStack(lua_State *state) {
318318

319319
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len)
320320
{
321-
if (input_len % 4 != 0) {
322-
/* we're using a buffer sized at a multiple of 4 as lua_pushlstring generates
323-
* invalid read errors in valgrind otherwise. Adding in a nul to be sure.
324-
*
325-
* Buffer size = len + 1 (for nul) + whatever makes it a multiple of 4 */
326-
size_t buflen = input_len + 1 + ((input_len + 1) % 4);
327-
uint8_t buf[buflen];
328-
memset(buf, 0x00, buflen);
329-
memcpy(buf, input, input_len);
330-
buf[input_len] = '\0';
331-
332-
/* return value through luastate, as a luastring */
333-
lua_pushlstring(luastate, (char *)buf, input_len);
334-
} else {
335-
lua_pushlstring(luastate, (char *)input, input_len);
336-
}
321+
lua_pushlstring(luastate, (char *)input, input_len);
337322
return 1;
338323
}
339324

0 commit comments

Comments
 (0)