Skip to content

Commit

Permalink
Bug 1775499 - check for null GetParentObject in Performance::Measure.…
Browse files Browse the repository at this point in the history
… r=sefeng

Root cause: the global object can be null but I wasn't checking for it so it
caused a crash. I don't remember under what conditions it can be null but I saw
I had checked for null when I wrote Performance::Mark and remember debugging it
so it makes sense to do so here as well.

Differential Revision: https://phabricator.services.mozilla.com/D151960
  • Loading branch information
mcomella committed Jul 25, 2022
1 parent 7feb2ef commit f9dff05
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dom/performance/Performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ already_AddRefed<PerformanceMeasure> Performance::Measure(
JSContext* aCx, const nsAString& aName,
const StringOrPerformanceMeasureOptions& aStartOrMeasureOptions,
const Optional<nsAString>& aEndMark, ErrorResult& aRv) {
if (!GetParentObject()) {
aRv.ThrowInvalidStateError("Global object is unavailable");
return nullptr;
}

// When resisting fingerprinting, we don't add marks to the buffer. Since
// measure relies on relationships between marks in the buffer, this method
// will throw if we look for user-entered marks so we return a dummy measure
Expand Down

0 comments on commit f9dff05

Please sign in to comment.