Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
899c0826
Commit
899c0826
authored
May 29, 2019
by
Abseil Team
Committed by
Gennadiy Civil
May 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Add a safety nullptr check to catch the case where the /tmp file used for capturing a stream cannot be created. PiperOrigin-RevId: 250523012
parent
f5edb4f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
CONTRIBUTING.md
CONTRIBUTING.md
+1
-2
gtest-port.cc
googletest/src/gtest-port.cc
+9
-0
No files found.
CONTRIBUTING.md
View file @
899c0826
...
@@ -20,8 +20,7 @@ instructions for how to sign and return it. Once we receive it, we'll be able to
...
@@ -20,8 +20,7 @@ instructions for how to sign and return it. Once we receive it, we'll be able to
accept your pull requests.
accept your pull requests.
## Are you a Googler?
## Are you a Googler?
If you are a Googler, plese make an attempt to submit an internal change rather than a GitHub Pull Request.
If you are a Googler, you can either create an internal change or work on GitHub directly.
If you are not able to submit an internal change a PR is acceptable as an alternative.
## Contributing A Patch
## Contributing A Patch
...
...
googletest/src/gtest-port.cc
View file @
899c0826
...
@@ -1113,6 +1113,11 @@ class CapturedStream {
...
@@ -1113,6 +1113,11 @@ class CapturedStream {
char
name_template
[]
=
"/tmp/captured_stream.XXXXXX"
;
char
name_template
[]
=
"/tmp/captured_stream.XXXXXX"
;
# endif // GTEST_OS_LINUX_ANDROID
# endif // GTEST_OS_LINUX_ANDROID
const
int
captured_fd
=
mkstemp
(
name_template
);
const
int
captured_fd
=
mkstemp
(
name_template
);
if
(
captured_fd
==
-
1
)
{
GTEST_LOG_
(
WARNING
)
<<
"Failed to create tmp file "
<<
name_template
<<
" for test; does the test have access to the /tmp directory?"
;
}
filename_
=
name_template
;
filename_
=
name_template
;
# endif // GTEST_OS_WINDOWS
# endif // GTEST_OS_WINDOWS
fflush
(
nullptr
);
fflush
(
nullptr
);
...
@@ -1134,6 +1139,10 @@ class CapturedStream {
...
@@ -1134,6 +1139,10 @@ class CapturedStream {
}
}
FILE
*
const
file
=
posix
::
FOpen
(
filename_
.
c_str
(),
"r"
);
FILE
*
const
file
=
posix
::
FOpen
(
filename_
.
c_str
(),
"r"
);
if
(
file
==
nullptr
)
{
GTEST_LOG_
(
FATAL
)
<<
"Failed to open tmp file "
<<
filename_
<<
" for capturing stream."
;
}
const
std
::
string
content
=
ReadEntireFile
(
file
);
const
std
::
string
content
=
ReadEntireFile
(
file
);
posix
::
FClose
(
file
);
posix
::
FClose
(
file
);
return
content
;
return
content
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment