Skip to content

Commit e2d6444

Browse files
committed
refactor: move is_head higher up in the function definition so we can free method_str.ptr
1 parent 17c5049 commit e2d6444

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

c-dependencies/js-compute-runtime/js-compute-builtins.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3849,17 +3849,18 @@ static bool init_downstream_request(JSContext *cx, HandleObject request) {
38493849
}
38503850

38513851
bool is_get = strncmp(method_str.ptr, "GET", method_str.len) == 0;
3852+
bool is_head = strncmp(method_str.ptr, "HEAD", method_str.len) == 0;
3853+
38523854
if (!is_get) {
38533855
RootedString method(cx, JS_NewStringCopyN(cx, method_str.ptr, method_str.len));
3856+
JS_free(cx, method_str.ptr);
38543857
if (!method) {
38553858
return false;
38563859
}
38573860

38583861
JS::SetReservedSlot(request, Request::Slots::Method, JS::StringValue(method));
38593862
}
38603863

3861-
bool is_head = strncmp(method_str.ptr, "HEAD", method_str.len) == 0;
3862-
38633864
// Set whether we have a body depending on the method.
38643865
// TODO: verify if that's right. I.e. whether we should treat all requests
38653866
// that are not GET or HEAD as having a body, which might just be 0-length.

0 commit comments

Comments
 (0)