1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

tiny_psnr: check fread() return values

Originally committed as revision 24148 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Måns Rullgård 2010-07-09 23:26:36 +00:00
parent 58d2b15447
commit cd3cb048d9

View File

@ -131,14 +131,17 @@ int main(int argc,char* argv[]){
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
uint8_t *p = buf[i]; uint8_t *p = buf[i];
fread(p, 1, 12, f[i]); if (fread(p, 1, 12, f[i]) != 12)
return 1;
if (!memcmp(p, "RIFF", 4) && if (!memcmp(p, "RIFF", 4) &&
!memcmp(p+8, "WAVE", 4)) { !memcmp(p+8, "WAVE", 4)) {
fread(p, 1, 8, f[i]); if (fread(p, 1, 8, f[i]) != 8)
return 1;
while (memcmp(p, "data", 4)) { while (memcmp(p, "data", 4)) {
int s = p[4] | p[5]<<8 | p[6]<<16 | p[7]<<24; int s = p[4] | p[5]<<8 | p[6]<<16 | p[7]<<24;
fseek(f[i], s, SEEK_CUR); fseek(f[i], s, SEEK_CUR);
fread(p, 1, 8, f[i]); if (fread(p, 1, 8, f[i]) != 8)
return 1;
} }
} else { } else {
fseek(f[i], -12, SEEK_CUR); fseek(f[i], -12, SEEK_CUR);