Commit 51291f88 authored by Alex Turner's avatar Alex Turner Committed by Commit Bot

Check whether ToString()'s result is empty in AdTracker::Will()

While AdTracker::Will() already checks if |resource_name| is empty, in
rare situations, the subsequent call to ToString() can still return an
empty result. This is the cause of a rare crash. To fix this, we check
whether the result is empty; if it is, we treat it in the same was as an
empty |resource_name|.

Bug: 1086832
Change-Id: Ie9d3a865c5a588a34f94034d55bba1ae67e6895e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225282Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775833}
parent 709cb68f
......@@ -158,9 +158,12 @@ void AdTracker::Will(const probe::CallFunction& probe) {
probe.function->GetScriptOrigin().ResourceName();
String script_url;
if (!resource_name.IsEmpty()) {
script_url = ToCoreString(
resource_name->ToString(ToIsolate(local_root_)->GetCurrentContext())
.ToLocalChecked());
v8::MaybeLocal<v8::String> resource_name_string =
resource_name->ToString(ToIsolate(local_root_)->GetCurrentContext());
// Rarely, ToString() can return an empty result, even if |resource_name|
// isn't empty (crbug.com/1086832).
if (!resource_name_string.IsEmpty())
script_url = ToCoreString(resource_name_string.ToLocalChecked());
}
WillExecuteScript(probe.context, script_url);
}
......
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