Commit 9dc7201c authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Do not leak memory in base::OS::FOpen.

R=petermarshall@chromium.org

Change-Id: Ie62129f39e1085a94737406dc07b07e359294c4e
Reviewed-on: https://chromium-review.googlesource.com/599813Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47152}
parent 0b0ee001
......@@ -400,7 +400,10 @@ FILE* OS::FOpen(const char* path, const char* mode) {
FILE* file = fopen(path, mode);
if (file == NULL) return NULL;
struct stat file_stat;
if (fstat(fileno(file), &file_stat) != 0) return NULL;
if (fstat(fileno(file), &file_stat) != 0) {
fclose(file);
return NULL;
}
bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
if (is_regular_file) return file;
fclose(file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment