From 868250d1964591cba826669e408285d52e14cf28 Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Fri, 27 Sep 2024 01:54:10 +0200 Subject: [PATCH] Fix bug in pd-vanilla implementation --- Makefile | 2 +- pdlua_gfx.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4d35806..739aeb1 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ luaflags += -DLUA_USE_WINDOWS endef endif -cflags = ${luaflags} -DPDLUA_VERSION="$(pdlua_version)" -fsanitize=address -g +cflags = ${luaflags} -DPDLUA_VERSION="$(pdlua_version)" pdlua.class.sources := pdlua.c $(luasrc) pdlua.class.ldlibs := $(lualibs) diff --git a/pdlua_gfx.h b/pdlua_gfx.h index 43c00fd..9d7a1c0 100644 --- a/pdlua_gfx.h +++ b/pdlua_gfx.h @@ -812,7 +812,9 @@ static int start_paint(lua_State* L) { int layer = luaL_checknumber(L, 2); if(layer >= gfx->num_layers) { - gfx->layer_tags = resizebytes(gfx->layer_tags, sizeof(char*) * gfx->num_layers, sizeof(char*) * ++gfx->num_layers); + int new_num_layers = layer + 1; + gfx->layer_tags = resizebytes(gfx->layer_tags, sizeof(char*) * gfx->num_layers, sizeof(char*) * new_num_layers); + gfx->num_layers = new_num_layers; gfx->layer_tags[layer] = malloc(64); snprintf(gfx->layer_tags[layer], 64, ".l%i%lx", layer, (long)obj); }