mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-10-03 09:27:53 +02:00
Merge commit '38129c26c51b933d7db423f904ba0cd6a88ca1ed'
* commit '38129c26c51b933d7db423f904ba0cd6a88ca1ed': cmdutils: check file access functions return values Conflicts: cmdutils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
934f2d2f5c
31
cmdutils.c
31
cmdutils.c
@ -1864,20 +1864,31 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
*size = ftell(f);
|
ret = fseek(f, 0, SEEK_END);
|
||||||
fseek(f, 0, SEEK_SET);
|
if (ret == -1) {
|
||||||
if (*size == (size_t)-1) {
|
|
||||||
ret = AVERROR(errno);
|
ret = AVERROR(errno);
|
||||||
av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", strerror(errno));
|
goto out;
|
||||||
fclose(f);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = ftell(f);
|
||||||
|
if (ret < 0) {
|
||||||
|
ret = AVERROR(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
*size = ret;
|
||||||
|
|
||||||
|
ret = fseek(f, 0, SEEK_SET);
|
||||||
|
if (ret == -1) {
|
||||||
|
ret = AVERROR(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
*bufptr = av_malloc(*size + 1);
|
*bufptr = av_malloc(*size + 1);
|
||||||
if (!*bufptr) {
|
if (!*bufptr) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
|
av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
|
||||||
fclose(f);
|
ret = AVERROR(ENOMEM);
|
||||||
return AVERROR(ENOMEM);
|
goto out;
|
||||||
}
|
}
|
||||||
ret = fread(*bufptr, 1, *size, f);
|
ret = fread(*bufptr, 1, *size, f);
|
||||||
if (ret < *size) {
|
if (ret < *size) {
|
||||||
@ -1893,6 +1904,8 @@ int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
|
|||||||
(*bufptr)[(*size)++] = '\0';
|
(*bufptr)[(*size)++] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", av_err2str(ret));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user