浏览代码

Shell: Eliminate possible use-after-free in builtin_fg()

This fixes a possible UAF where the job might be destroyed in
block_on_job().
AnotherTest 5 年之前
父节点
当前提交
7aa5a2bc0f
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Shell/Builtin.cpp

+ 1 - 1
Shell/Builtin.cpp

@@ -332,7 +332,7 @@ int Shell::builtin_fg(int argc, const char** argv)
     if (job_id == -1 && !jobs.is_empty())
         job_id = find_last_job_id();
 
-    auto* job = const_cast<Job*>(find_job(job_id));
+    RefPtr<Job> job = find_job(job_id);
 
     if (!job) {
         if (job_id == -1) {