fix(color): Memory leaks when using USB mass storage connection (#3547)

* Fix memory leaks when using 'USB Storage (SD)' connection.
- Lua state 'cache' allocated to both lsScripts and lsWidgets; but only one was being released.
- Default theme bitmaps being reloaded without releasing previously allocated memory.

* Fix icons.
This commit is contained in:
philmoz
2023-05-17 18:28:29 +10:00
committed by GitHub
parent ce5d62af78
commit f2936931f7
2 changed files with 40 additions and 49 deletions
+5 -9
View File
@@ -309,18 +309,14 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
g->gcpause = LUAI_GCPAUSE;
g->gcmajorinc = LUAI_GCMAJOR;
g->gcstepmul = LUAI_GCMUL;
#ifdef LUA_ENABLE_TEST
if (L0) { /* This is a second state */
g->cache=G(L0)->cache;
g->cache = G(L0)->cache;
} else {
#endif
L0 = L;
g->cache = cast(KeyCacheLine *,
(*f)(ud, NULL, 0, KEYCACHE_N * sizeof(KeyCacheLine)));
memset(g->cache, 0, KEYCACHE_N * sizeof(KeyCacheLine));
#ifdef LUA_ENABLE_TEST
L0 = L;
g->cache = cast(KeyCacheLine *,
(*f)(ud, NULL, 0, KEYCACHE_N * sizeof(KeyCacheLine)));
memset(g->cache, 0, KEYCACHE_N * sizeof(KeyCacheLine));
}
#endif
for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;
if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) {
/* memory allocation error: free partial state */