From 4f22fd29be478e285212bcc806b6aff131ac4692 Mon Sep 17 00:00:00 2001 From: CrazyRedMachine Date: Mon, 22 Apr 2024 00:20:41 +0200 Subject: [PATCH] fix crash --- popnhax/custom_categs.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/popnhax/custom_categs.cc b/popnhax/custom_categs.cc index c68d857..8984bce 100644 --- a/popnhax/custom_categs.cc +++ b/popnhax/custom_categs.cc @@ -322,7 +322,7 @@ void hook_categ_build_songlist() __asm("push ecx\n"); __asm("push edx\n"); __asm("sub esp, 0x08\n"); - songlist = (uint32_t*)realloc((void*)songlist, sizeof(uint32_t)*(songlist_count+1)); //TODO: only realloc when growing + songlist = (uint32_t*)realloc((void*)songlist, sizeof(uint32_t)*(songlist_count+4)); //TODO: only realloc when growing songlist_addr = (uint32_t)songlist; __asm("add esp, 0x08\n"); __asm("pop edx\n"); @@ -592,6 +592,9 @@ bool patch_custom_categs(const char *dllFilename, uint8_t mode, uint16_t min, ui { g_min_id = min; g_max_id = max; + #if SIMPLE_CATEG_ALLOC == 1 + songlist = (uint32_t*)calloc(1,5); + #endif if (mode == 2) { g_subcategmode = true;