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>
off_t off_size;
char errbuf[128];
*bufptr = NULL;
+ *size = 0;
if (fd < 0) {
err = AVERROR(errno);
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;
if (!mh) {
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in CreateFileMapping()\n");
close(fd);
+ *size = 0;
return -1;
}
if (!ptr) {
av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in MapViewOfFile()\n");
close(fd);
+ *size = 0;
return -1;
}
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);