diff --git a/builtins/web/fetch/headers.cpp b/builtins/web/fetch/headers.cpp index 915a48e..085a99c 100644 --- a/builtins/web/fetch/headers.cpp +++ b/builtins/web/fetch/headers.cpp @@ -1015,6 +1015,21 @@ bool Headers::constructor(JSContext *cx, unsigned argc, JS::Value *vp) { return true; } +void Headers::finalize(JS::GCContext *gcx, JSObject *self) { + HeadersList *list = static_cast( + JS::GetReservedSlot(self, static_cast(Headers::Slots::HeadersList)).toPrivate()); + if (list != nullptr) { + list->clear(); + free(list); + } + HeadersSortList *sort_list = static_cast( + JS::GetReservedSlot(self, static_cast(Slots::HeadersSortList)).toPrivate()); + if (sort_list != nullptr) { + sort_list->clear(); + free(sort_list); + } +} + bool Headers::init_class(JSContext *cx, JS::HandleObject global) { // get the host forbidden headers for guard checks forbidden_request_headers = &host_api::HttpHeaders::get_forbidden_request_headers(); diff --git a/builtins/web/fetch/headers.h b/builtins/web/fetch/headers.h index aba1685..d5f5633 100644 --- a/builtins/web/fetch/headers.h +++ b/builtins/web/fetch/headers.h @@ -8,7 +8,7 @@ namespace builtins { namespace web { namespace fetch { -class Headers final : public BuiltinImpl { +class Headers final : public FinalizableBuiltinImpl { static bool append(JSContext *cx, unsigned argc, JS::Value *vp); static bool delete_(JSContext *cx, unsigned argc, JS::Value *vp); static bool entries(JSContext *cx, unsigned argc, JS::Value *vp); @@ -127,6 +127,8 @@ class Headers final : public BuiltinImpl { static JSObject *create(JSContext *cx, HandleValue init_headers, HeadersGuard guard); static JSObject *create(JSContext *cx, host_api::HttpHeadersReadOnly *handle, HeadersGuard guard); + static void finalize(JS::GCContext *gcx, JSObject *obj); + static bool init_entries(JSContext *cx, HandleObject self, HandleValue init_headers); /// Returns the headers list of entries, constructing it if necessary. diff --git a/builtins/web/url.cpp b/builtins/web/url.cpp index 98ebb9c..03c4c91 100644 --- a/builtins/web/url.cpp +++ b/builtins/web/url.cpp @@ -581,7 +581,8 @@ JSObject *URL::create(JSContext *cx, JS::HandleObject self, JS::HandleValue url_ } void URL::finalize(JS::GCContext *gcx, JSObject *self) { - jsurl::JSUrl* url = static_cast(JS::GetReservedSlot(self, Slots::Url).toPrivate()); + jsurl::JSUrl *url = + static_cast(JS::GetReservedSlot(self, Slots::Url).toPrivate()); free(url); }