Skip to content

Commit

Permalink
Fetch Body: fix deference of null ExecutionContext
Browse files Browse the repository at this point in the history
The body attribute on the Body type accessed the ExecutionContext in
order to log a use counter, but didn't check if it was null. Add a null
check.

BUG=1034833

Change-Id: I424b1eae9140804b227d4c9a34bd75e494729722
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2000409
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731909}
  • Loading branch information
ricea authored and Commit Bot committed Jan 15, 2020
1 parent 2638d76 commit c8c4e60
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions third_party/blink/renderer/core/fetch/body.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,13 @@ ScriptPromise Body::text(ScriptState* script_state,
}

ReadableStream* Body::body() {
auto* execution_context = GetExecutionContext();
if (execution_context->IsServiceWorkerGlobalScope()) {
execution_context->CountUse(WebFeature::kFetchBodyStreamInServiceWorker);
} else {
execution_context->CountUse(
WebFeature::kFetchBodyStreamOutsideServiceWorker);
if (auto* execution_context = GetExecutionContext()) {
if (execution_context->IsServiceWorkerGlobalScope()) {
execution_context->CountUse(WebFeature::kFetchBodyStreamInServiceWorker);
} else {
execution_context->CountUse(
WebFeature::kFetchBodyStreamOutsideServiceWorker);
}
}

if (!BodyBuffer())
Expand Down

0 comments on commit c8c4e60

Please sign in to comment.