From 0afb67b5a7feb138a4465790696c51e0a8fd52bf Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 23 Mar 2024 23:59:27 +0100 Subject: [PATCH] cleanup: fix leaks/overread --- src/coding/hca_decoder_clhca.c | 4 +++- src/meta/acb.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/coding/hca_decoder_clhca.c b/src/coding/hca_decoder_clhca.c index 7c905eb4..2b0dd179 100644 --- a/src/coding/hca_decoder_clhca.c +++ b/src/coding/hca_decoder_clhca.c @@ -219,7 +219,9 @@ static unsigned int bitreader_peek(clData* br, int bitsize) { unsigned int v = 0; unsigned int bit_offset, bit_left; - if (!(bit + bitsize <= size)) + if (bit + bitsize > size) + return v; + if (bitsize == 0) /* may happen when resolution is 0 (dequantize_coefficients) */ return v; bit_offset = bitsize + bit_rem; diff --git a/src/meta/acb.c b/src/meta/acb.c index 280187f0..4b462837 100644 --- a/src/meta/acb.c +++ b/src/meta/acb.c @@ -1055,8 +1055,11 @@ static int preload_acb_cuename(acb_header* acb) { if (*p_rows) return 1; + if (!open_utf_subtable(acb, &acb->CueNameSf, &Table, "CueNameTable", p_rows, ACB_TABLE_BUFFER_CUENAME)) goto fail; + acb->CueNames = Table; /* keep this table around since we need CueName pointers */ + if (!*p_rows) return 1; //;VGM_LOG("acb: preload CueName=%i\n", *p_rows); @@ -1074,7 +1077,7 @@ static int preload_acb_cuename(acb_header* acb) { utf_query_col_string(Table, i, c_CueName, &r->CueName); } - //utf_close(Table); /* keep this table around since we need CueName pointers */ + //utf_close(Table); /* released at the end */ return 1; fail: VGM_LOG("acb: failed CueName preload\n"); @@ -1245,6 +1248,7 @@ void load_acb_wave_info(STREAMFILE* sf, VGMSTREAM* vgmstream, int waveid, int po /* done */ fail: +VGM_LOG("close %x\n", (uint32_t)acb.CueNames); utf_close(acb.Header); utf_close(acb.CueNames);