Skip to content

Commit

Permalink
Revert "libhb: don't ignore the return result from fread()"
Browse files Browse the repository at this point in the history
Broke image previews on Linux and Windows (mingw).

This reverts commit b7645e7.
  • Loading branch information
bradleysepos committed Jul 7, 2016
1 parent a923c2a commit d332d4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
6 changes: 1 addition & 5 deletions libhb/encavcodec.c
Expand Up @@ -302,11 +302,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
fseek( pv->file, 0, SEEK_SET );
log = malloc( size + 1 );
log[size] = '\0';
if (size > 0 &&
fread( log, size, 1, pv->file ) < size)
{
hb_log( "encavcodecInit: Failed to read %s" , filename);
}
fread( log, size, 1, pv->file );
fclose( pv->file );
pv->file = NULL;

Expand Down
8 changes: 1 addition & 7 deletions libhb/hb.c
Expand Up @@ -696,13 +696,7 @@ hb_buffer_t * hb_read_preview(hb_handle_t * h, hb_title_t *title, int preview)

for (hh = 0; hh < h; hh++)
{
if (fread(data, w, 1, file) < w)
{
hb_error( "hb_read_preview: Failed to read line %d from %s" , hh, filename );
hb_buffer_close(&buf);
break;
}

fread(data, w, 1, file);
data += stride;
}
}
Expand Down
19 changes: 7 additions & 12 deletions libhb/stream.c
Expand Up @@ -3280,24 +3280,19 @@ static int hb_ps_read_packet( hb_stream_t * stream, hb_buffer_t *b )
hb_buffer_realloc( b, b->alloc * 2 );
}

// There are (hopefully) at least 8 bytes. More if this is mpeg2 pack.
if (fread( cp+pos, 1, 8, stream->file_handle ) < 8)
goto done;
// There are at least 8 bytes. More if this is mpeg2 pack.
fread( cp+pos, 1, 8, stream->file_handle );
int mark = cp[pos] >> 4;
pos += 8;

if ( mark != 0x02 )
{
// mpeg-2 pack,
if (fread( cp+pos, 1, 2, stream->file_handle ) == 2)
{
int len;
pos += 2;
len = cp[start+13] & 0x7;
if (len > 0 &&
fread( cp+pos, 1, len, stream->file_handle ) == len)
pos += len;
}
fread( cp+pos, 1, 2, stream->file_handle );
pos += 2;
int len = cp[start+13] & 0x7;
fread( cp+pos, 1, len, stream->file_handle );
pos += len;
}
}
// Non-video streams can emulate start codes, so we need
Expand Down

0 comments on commit d332d4d

Please sign in to comment.