Skip to content

Commit 9cc5316

Browse files
Sackzementicculus
authored andcommitted
decoder_voc: fix possible use-after-free again
1 parent f73f204 commit 9cc5316

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/decoder_voc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ static bool ParseVocFile(SDL_IOStream *io, VOC_AudioData *adata, SDL_PropertiesI
108108
{
109109
Sint64 total_frames = 0;
110110
VOC_Block *loop_start = NULL;
111+
int loop_start_loop_count = 0;
111112
Sint64 loop_frames = 0;
112113
SDL_AudioSpec original_spec;
113114
SDL_AudioSpec current_spec;
@@ -280,6 +281,7 @@ static bool ParseVocFile(SDL_IOStream *io, VOC_AudioData *adata, SDL_PropertiesI
280281
if (!loop_start) {
281282
return false;
282283
}
284+
loop_start_loop_count = loop_start->loop_count;
283285
break;
284286
}
285287

@@ -288,17 +290,17 @@ static bool ParseVocFile(SDL_IOStream *io, VOC_AudioData *adata, SDL_PropertiesI
288290
return SDL_SetError("VOC has a LOOPEND without a matching LOOP");
289291
}
290292

291-
const int loopcnt = loop_start->loop_count;
292293
VOC_Block *block = AddVocLoopBlock(adata, -2);
293294
if (!block) {
294295
return false;
295296
}
296297

297298
if (total_frames != -1) {
298-
total_frames += loop_frames * loopcnt;
299+
total_frames += loop_frames * loop_start_loop_count;
299300
}
300301

301302
loop_start = NULL;
303+
loop_start_loop_count = 0;
302304
loop_frames = 0;
303305
break;
304306
}

0 commit comments

Comments
 (0)