History

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

Jun Zhao committed 7 years ago

Commit 7ce15b11 parent 7c0b3ba1 file · +5 −0Browse files

Unified · Split

libavutil/file.c+5−0
@@ -60,6 +60,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, · 59 unmodified lines
6060 off_t off_size;
6161 char errbuf[128];
6262 *bufptr = NULL;
63+ *size = 0;
6364
6465 if (fd < 0) {
6566 err = AVERROR(errno);
@@ -97,6 +98,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, · 31 unmodified lines
9798 av_strerror(err, errbuf, sizeof(errbuf));
9899 av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in mmap(): %s\n", errbuf);
99100 close(fd);
101+ *size = 0;
100102 return err;
101103 }
102104 *bufptr = ptr;
@@ -108,6 +110,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, · 5 unmodified lines
108110 if (!mh) {
109111 av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in CreateFileMapping()\n");
110112 close(fd);
113+ *size = 0;
111114 return -1;
112115 }
113116
@@ -116,6 +119,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, · 2 unmodified lines
116119 if (!ptr) {
117120 av_log(&file_log_ctx, AV_LOG_ERROR, "Error occurred in MapViewOfFile()\n");
118121 close(fd);
122+ *size = 0;
119123 return -1;
120124 }
121125
@@ -126,6 +130,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, · 4 unmodified lines
126130 if (!*bufptr) {
127131 av_log(&file_log_ctx, AV_LOG_ERROR, "Memory allocation error occurred\n");
128132 close(fd);
133+ *size = 0;
129134 return AVERROR(ENOMEM);
130135 }
131136 read(fd, *bufptr, *size);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t