audio/flacdec: handle read errors properly to avoid endless looping saturating cpu
This commit is contained in:
parent
876907a530
commit
a72a4c8b91
1 changed files with 4 additions and 3 deletions
|
@ -25,10 +25,11 @@ decinput(FLAC__StreamDecoder *dec, FLAC__byte buffer[], size_t *bytes, void *cli
|
||||||
int n = *bytes;
|
int n = *bytes;
|
||||||
|
|
||||||
n = fread(buffer, 1, n, stdin);
|
n = fread(buffer, 1, n, stdin);
|
||||||
if(n < 0)
|
if(n < 1){
|
||||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
if(feof(stdin))
|
||||||
if(n == 0)
|
|
||||||
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||||
|
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||||
|
}
|
||||||
|
|
||||||
*bytes = n;
|
*bytes = n;
|
||||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||||
|
|
Loading…
Reference in a new issue