aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/file.c
diff options
context:
space:
mode:
authorJun Zhao <barryjzhao@tencent.com>2019-08-29 00:15:52 +0800
committerJun Zhao <barryjzhao@tencent.com>2019-08-30 09:15:43 +0800
commit7ce15b1d439400cba1aa09e9ee80aacbd84eb988 (patch)
tree10730390be2023a1028559140af07de79230f2b5 /libavutil/file.c
parent7c0b3ba7ddaa6540560c8b7884697a7487b669e4 (diff)
downloadffmpeg-7ce15b1d439400cba1aa09e9ee80aacbd84eb988.tar.gz
avutil/file: always set *size to zero if *bufptr is NULL
Always set *size to zero if *bufptr is NULL, it's more make sence. fix #8095 Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Diffstat (limited to 'libavutil/file.c')
-rw-r--r--libavutil/file.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavutil/file.c b/libavutil/file.c
index d946085b28..b91c2fa391 100644
--- a/libavutil/file.c
+++ b/libavutil/file.c
@@ -60,6 +60,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
off_t off_size;
char errbuf[128];
*bufptr = NULL;
+ *size = 0;
if (fd < 0) {
err = AVERROR(errno);
@@ -97,6 +98,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
av_strerror(err, errbuf, sizeof(errbuf));
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in mmap(): %s\n", errbuf);
close(fd);
+ *size = 0;
return err;
}
*bufptr = ptr;
@@ -108,6 +110,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
if (!mh) {
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in CreateFileMapping()\n");
close(fd);
+ *size = 0;
return -1;
}
@@ -116,6 +119,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
if (!ptr) {
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in MapViewOfFile()\n");
close(fd);
+ *size = 0;
return -1;
}
@@ -126,6 +130,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
if (!*bufptr) {
av_log(&file_log_ctx, AV_LOG_ERROR, "Memory allocation error occurred\n");
close(fd);
+ *size = 0;
return AVERROR(ENOMEM);
}
read(fd, *bufptr, *size);