Commit 5751d8f5 authored by lukezarko's avatar lukezarko

Avoid a potential null dereference wrt the CPU profiler.

GetActiveProfilerModules()/PauseProfiler()/ResumeProfiler() can be reached
from the API when the --prof runtime flag is not set, leading to null
dereferences. Verify that Logger::profiler_ is non-NULL before using it.

Review URL: http://codereview.chromium.org/2843023

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4953 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 49c47184
......@@ -309,10 +309,10 @@ void Profiler::Disengage() {
void Profiler::Run() {
TickSample sample;
bool overflow = Logger::profiler_->Remove(&sample);
bool overflow = Remove(&sample);
while (running_) {
LOG(TickEvent(&sample, overflow));
overflow = Logger::profiler_->Remove(&sample);
overflow = Remove(&sample);
}
}
......@@ -1150,7 +1150,7 @@ void Logger::TickEvent(TickSample* sample, bool overflow) {
int Logger::GetActiveProfilerModules() {
int result = PROFILER_MODULE_NONE;
if (!profiler_->paused()) {
if (profiler_ != NULL && !profiler_->paused()) {
result |= PROFILER_MODULE_CPU;
}
if (FLAG_log_gc) {
......@@ -1162,7 +1162,7 @@ int Logger::GetActiveProfilerModules() {
void Logger::PauseProfiler(int flags, int tag) {
if (!Log::IsEnabled()) return;
if (flags & PROFILER_MODULE_CPU) {
if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) {
// It is OK to have negative nesting.
if (--cpu_profiler_nesting_ == 0) {
profiler_->pause();
......@@ -1193,7 +1193,7 @@ void Logger::ResumeProfiler(int flags, int tag) {
if (tag != 0) {
UncheckedIntEvent("open-tag", tag);
}
if (flags & PROFILER_MODULE_CPU) {
if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) {
if (cpu_profiler_nesting_++ == 0) {
++logging_nesting_;
if (FLAG_prof_lazy) {
......
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