Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: webrtc/base/event_tracer.cc

Issue 2961663002: Trace loggging: Check for g_event_logger is not null before calling it. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/base/event_tracer.cc
diff --git a/webrtc/base/event_tracer.cc b/webrtc/base/event_tracer.cc
index cb7554a891f6db4dd566c6c3c4f4c92333adf652..24ab99acf14b3dba2228073aa78d8e3b408485fa 100644
--- a/webrtc/base/event_tracer.cc
+++ b/webrtc/base/event_tracer.cc
@@ -374,22 +374,30 @@ void SetupInternalTracer() {
}
void StartInternalCaptureToFile(FILE* file) {
- g_event_logger->Start(file, false);
+ if (g_event_logger) {
tkchin_webrtc 2017/06/27 22:56:40 I'm not sure how thread-safe this check is. Ask ow
jtt_webrtc 2017/06/28 17:44:25 The only time g_event_logger is changed is when Se
+ g_event_logger->Start(file, false);
+ }
}
bool StartInternalCapture(const char* filename) {
- FILE* file = fopen(filename, "w");
- if (!file) {
- LOG(LS_ERROR) << "Failed to open trace file '" << filename
- << "' for writing.";
+ if (g_event_logger) {
+ FILE* file = fopen(filename, "w");
+ if (!file) {
+ LOG(LS_ERROR) << "Failed to open trace file '" << filename
+ << "' for writing.";
+ return false;
+ }
+ g_event_logger->Start(file, true);
+ return true;
+ } else {
return false;
}
- g_event_logger->Start(file, true);
- return true;
}
void StopInternalCapture() {
- g_event_logger->Stop();
+ if (g_event_logger) {
+ g_event_logger->Stop();
+ }
}
void ShutdownInternalTracer() {

Powered by Google App Engine
This is Rietveld 408576698