summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-07-19 21:52:07 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2021-08-03 11:02:15 +0000
commit074daea51f4dc31afa8b5617db839c96fb76c06d (patch)
treee285dc1c057fc6995562e96622c5a4bb8e687612
parent1fd190d02dfbb10f5e02a98bd20b698e14e0a5bc (diff)
downloadrockbox-074daea51f4dc31afa8b5617db839c96fb76c06d.tar.gz
rockbox-074daea51f4dc31afa8b5617db839c96fb76c06d.tar.bz2
rockbox-074daea51f4dc31afa8b5617db839c96fb76c06d.zip
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
-rw-r--r--apps/plugins/lua/lcode.c6
1 files changed, 4 insertions, 2 deletions
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;
}