From 074daea51f4dc31afa8b5617db839c96fb76c06d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 19 Jul 2021 21:52:07 -0400 Subject: lua fix potential null warning I'm not sure this would happen but I suspect its possible to get malformed data back from lineinfo as this is how the error system tracks code flow and this is a hacked add-on to allow RLE (run length encoding) of said code flow data Change-Id: I4b914c632935f8b1a9fa960212c58e810b2db738 --- apps/plugins/lua/lcode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apps/plugins/lua') diff --git a/apps/plugins/lua/lcode.c b/apps/plugins/lua/lcode.c index 18102d460e..bf031436e8 100644 --- a/apps/plugins/lua/lcode.c +++ b/apps/plugins/lua/lcode.c @@ -802,8 +802,10 @@ static unsigned char *growLineInfo(FuncState *fs) { unsigned char, MAX_INT, "code size overflow"); p = &f->packedlineinfo[start]; - memset(p, INFO_FILL_BYTE, f->sizelineinfo - start); - f->packedlineinfo[f->sizelineinfo - 1] = '\0'; + if (p && f->sizelineinfo > 0) { + memset(p, INFO_FILL_BYTE, f->sizelineinfo - start); + f->packedlineinfo[f->sizelineinfo - 1] = '\0'; + } return p; } -- cgit