Skip to content

Commit

Permalink
Set vm.cart->sprites to NULL after freeing it to avoid use-after-free
Browse files Browse the repository at this point in the history
  • Loading branch information
MineRobber9000 committed Mar 15, 2024
1 parent 363833f commit 29d271f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/nexus.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ static void UpdateDrawFrame(void)
}
EndTextureMode();
CloseLua();
if (vm.cart->sprites) FreeSprites(vm.cart->sprites); // free sprites on reset
if (vm.cart->sprites) {
FreeSprites(vm.cart->sprites); // free sprites on reset
vm.cart->sprites = NULL;
}
InitLua();
LoadString(vm.cart->code,vm.cart->code_size);
if (DoCall(0,0)!=LUA_OK) {
Expand Down

0 comments on commit 29d271f

Please sign in to comment.