Skip to content

Commit fe2c92e

Browse files
authored
fix: Correct URL finalizer for when the URL is undefined (#336)
* fix: Correct URL finalizer for when the URL is undefined * add missing braces
1 parent a46051a commit fe2c92e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎builtins/web/url.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,12 @@ JSObject *URL::create(JSContext *cx, JS::HandleObject self, JS::HandleValue url_
806806
}
807807

808808
void URL::finalize(JS::GCContext *gcx, JSObject *self) {
809-
auto *url =
810-
static_cast<jsurl::JSUrl *>(JS::GetReservedSlot(self, std::to_underlying(Slots::Url)).toPrivate());
809+
auto url_val = JS::GetReservedSlot(self, std::to_underlying(Slots::Url));
810+
if (url_val.isUndefined()) {
811+
return;
812+
}
813+
814+
auto *url = static_cast<jsurl::JSUrl *>(url_val.toPrivate());
811815
jsurl::free_jsurl(url);
812816
}
813817

0 commit comments

Comments
 (0)