cleanup: fix leaks/overread

This commit is contained in:
bnnm 2024-03-23 23:59:27 +01:00
parent 1ed15ed25a
commit 0afb67b5a7
2 changed files with 8 additions and 2 deletions

View File

@ -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;

View File

@ -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);