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>

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();
})();