Fix crash on inspector setScriptSource calls when source is unchanged

Bug: chromium:1059746
Change-Id: I309c15a33a7185c9397b7893a9eefcb90981dc64
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2280085
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68713}
This commit is contained in:
Aaron O'Mullan 2020-07-03 00:17:38 +02:00 committed by Commit Bot
parent 3ccf0d30fa
commit 0300dd8ba2
4 changed files with 22 additions and 2 deletions

View File

@ -42,6 +42,7 @@ Cloudflare, Inc. <*@cloudflare.com>
Julia Computing, Inc. <*@juliacomputing.com>
Aaron Bieber <deftly@gmail.com>
Aaron O'Mullan <aaron.omullan@gmail.com>
Abdulla Kamar <abdulla.kamar@gmail.com>
Adam Kallai <kadam@inf.u-szeged.hu>
Akinori MUSHA <knu@FreeBSD.org>
@ -216,4 +217,4 @@ Zhongping Wang <kewpie.w.zp@gmail.com>
柳荣一 <admin@web-tinker.com>
Yanbo Li <lybvinci@gmail.com>
Gilang Mentari Hamidy <gilang@hamidy.net>
Zeynep Cankara <zeynepcankara402@gmail.com>
Zeynep Cankara <zeynepcankara402@gmail.com>

View File

@ -174,7 +174,9 @@ class ActualScript : public V8DebuggerScript {
result->message = scope.Escape(result->message);
return;
}
if (preview) return;
// NOP if preview or unchanged source (diffs.empty() in PatchScript)
if (preview || result->script.IsEmpty()) return;
m_hash = String16();
Initialize(scope.Escape(result->script));
}

View File

@ -0,0 +1 @@
Check that setScriptSource does not crash when source is unchanged

View File

@ -0,0 +1,16 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
let {session, contextGroup, Protocol} =
InspectorTest.start('Check that setScriptSource does not crash when source is unchanged');
let scriptSource = `function TestExpression() {}`;
contextGroup.addScript(scriptSource);
(async function test() {
Protocol.Debugger.enable();
const {params: {scriptId}} = await Protocol.Debugger.onceScriptParsed();
await Protocol.Debugger.setScriptSource({scriptId, scriptSource});
InspectorTest.completeTest();
})();