mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-25 00:32:31 +00:00
cmdutils: check fread() return value
This commit is contained in:
parent
7d1b17b833
commit
d94c577d3c
18
cmdutils.c
18
cmdutils.c
@ -787,6 +787,7 @@ int read_yesno(void)
|
||||
|
||||
int read_file(const char *filename, char **bufptr, size_t *size)
|
||||
{
|
||||
int ret;
|
||||
FILE *f = fopen(filename, "rb");
|
||||
|
||||
if (!f) {
|
||||
@ -802,11 +803,22 @@ int read_file(const char *filename, char **bufptr, size_t *size)
|
||||
fclose(f);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
fread(*bufptr, 1, *size, f);
|
||||
(*bufptr)[*size++] = '\0';
|
||||
ret = fread(*bufptr, 1, *size, f);
|
||||
if (ret < *size) {
|
||||
av_free(*bufptr);
|
||||
if (ferror(f)) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
|
||||
filename, strerror(errno));
|
||||
ret = AVERROR(errno);
|
||||
} else
|
||||
ret = AVERROR_EOF;
|
||||
} else {
|
||||
ret = 0;
|
||||
(*bufptr)[*size++] = '\0';
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void init_pts_correction(PtsCorrectionContext *ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user