diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 19:05:53 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 19:05:53 +0000 |
commit | 139063bde77b1a837b12e746675a1ecf5d2caa87 (patch) | |
tree | d615eac8b532b9effdfd5168f92a30ff1dfcaabf /base | |
parent | 455cbb742da53fc56abe363c4a51f2a9e0fdcacb (diff) | |
download | chromium_src-139063bde77b1a837b12e746675a1ecf5d2caa87.zip chromium_src-139063bde77b1a837b12e746675a1ecf5d2caa87.tar.gz chromium_src-139063bde77b1a837b12e746675a1ecf5d2caa87.tar.bz2 |
GTTF: Correctly handle fdopen failure in CreateAndOpenTemporaryFileInDir
This avoids a possible fd leak when fdopen fails.
BUG=none
Review URL: http://codereview.chromium.org/6882014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util_posix.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index f25bd5c..803d610 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -435,7 +435,10 @@ FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) { if (fd < 0) return NULL; - return fdopen(fd, "a+"); + FILE* file = fdopen(fd, "a+"); + if (!file) + ignore_result(HANDLE_EINTR(close(fd))); + return file; } bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) { |