From 1a10d8f6277d67d13e71b46bcaa45692be412478 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Wed, 21 Dec 2022 06:15:05 +0100 Subject: [PATCH] Fix AdpcmBook allocations (#2214) --- soh/include/z64audio.h | 2 +- soh/soh/OTRGlobals.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/include/z64audio.h b/soh/include/z64audio.h index 0e602f9d8..2c0d41aad 100644 --- a/soh/include/z64audio.h +++ b/soh/include/z64audio.h @@ -127,7 +127,7 @@ typedef struct { typedef struct { /* 0x00 */ s32 order; /* 0x04 */ s32 npredictors; - /* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned + /* 0x08 */ s16 book[]; // size 8 * order * npredictors. 8-byte aligned } AdpcmBook; // size >= 0x8 typedef struct diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index d75eef2a2..0e698f999 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1137,7 +1137,7 @@ extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) sampleC->unk_bit26 = sample->unk_bit26; sampleC->unk_bit25 = sample->unk_bit25; - sampleC->book = new AdpcmBook[sample->book.books.size() * sizeof(int16_t)]; + sampleC->book = (AdpcmBook*) malloc(sizeof(AdpcmBook) + sample->book.books.size() * sizeof(int16_t)); sampleC->book->npredictors = sample->book.npredictors; sampleC->book->order = sample->book.order;