summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-27 10:41:32 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-27 10:41:32 +0100
commit79e79ad1d2f53d8dfb034df01cb5f1735478c941 (patch)
treeba10303c8c1d0700357de2789b99bc7a3c5be552 /Kernel
parent9632388bed0a81addd5878c32f5db822d0c97945 (diff)
downloadserenity-79e79ad1d2f53d8dfb034df01cb5f1735478c941.zip
Kernel: Don't blindly dereference Process::executable()
When setting up profiling, don't assume that the profiled process has a valid executable.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Profiling.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/Kernel/Profiling.cpp b/Kernel/Profiling.cpp
index 1c64512ba9..dba5cb8710 100644
--- a/Kernel/Profiling.cpp
+++ b/Kernel/Profiling.cpp
@@ -40,7 +40,6 @@ namespace Profiling {
static KBufferImpl* s_profiling_buffer;
static size_t s_slot_count;
static size_t s_next_slot_index;
-static Process* s_process;
static u32 s_pid;
String& executable_path()
@@ -58,9 +57,10 @@ u32 pid()
void start(Process& process)
{
- s_process = &process;
-
- executable_path() = process.executable()->absolute_path().impl();
+ if (process.executable())
+ executable_path() = process.executable()->absolute_path().impl();
+ else
+ executable_path() = {};
s_pid = process.pid();
if (!s_profiling_buffer) {
@@ -87,7 +87,6 @@ Sample& next_sample_slot()
void stop()
{
- s_process = nullptr;
}
void did_exec(const String& new_executable_path)