1
0

matroskadec_haali: Free the data block in case of read errors

Read Errors can typically happen at EOF, or when stopping playback
prematurely, making this case more common then one might expect.
This commit is contained in:
Hendrik Leppkes 2019-09-11 11:15:58 +02:00
parent f1501b5765
commit cd89e0cb7b
Signed by: hendrik
GPG Key ID: 846079A4B0A7C1B5

View File

@ -2346,6 +2346,7 @@ static void parseBlockGroup(MatroskaFile *mf,ulonglong toplen,ulonglong timecode
unsigned nframes = 0,i;
unsigned *sizes;
signed short block_timecode;
jmp_buf jb;
if (blockex)
goto blockex;
@ -2440,6 +2441,16 @@ found:
break;
}
// we need to free the packet in case of errors here
memcpy(&jb, &mf->jb, sizeof(jb));
if (setjmp(mf->jb)) {
QFree(mf, qe);
// jump to the top level handler
memcpy(&mf->jb, &jb, sizeof(jb));
longjmp(mf->jb, 1);
}
v = filepos(mf);
qf = NULL;
for (i=0;i<nframes;++i) {
@ -2465,6 +2476,8 @@ found:
v += sizes[i];
}
memcpy(&mf->jb, &jb, sizeof(jb));
// we want to still load these bytes into cache
for (v = filepos(mf) & ~0x3fff; v < len + dpos; v += 0x4000)
mf->cache->read(mf->cache,v,NULL,0); // touch page