Skip to content

Commit 17c5049

Browse files
Jake ChampionJakeChampion
authored andcommitted
fix: do not free the method_str.ptr as we still require the memory
fixes #352
1 parent f026dcf commit 17c5049

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
@@ -3851,19 +3851,20 @@ static bool init_downstream_request(JSContext *cx, HandleObject request) {
38513851
bool is_get = strncmp(method_str.ptr, "GET", method_str.len) == 0;
38523852
if (!is_get) {
38533853
RootedString method(cx, JS_NewStringCopyN(cx, method_str.ptr, method_str.len));
3854-
JS_free(cx, method_str.ptr);
38553854
if (!method) {
38563855
return false;
38573856
}
38583857

38593858
JS::SetReservedSlot(request, Request::Slots::Method, JS::StringValue(method));
38603859
}
38613860

3861+
bool is_head = strncmp(method_str.ptr, "HEAD", method_str.len) == 0;
3862+
38623863
// Set whether we have a body depending on the method.
38633864
// TODO: verify if that's right. I.e. whether we should treat all requests
38643865
// that are not GET or HEAD as having a body, which might just be 0-length.
38653866
// It's not entirely clear what else we even could do here though.
3866-
if (!(is_get || strncmp(method_str.ptr, "HEAD", method_str.len) == 0)) {
3867+
if (!is_get && !is_head) {
38673868
JS::SetReservedSlot(request, Request::Slots::HasBody, JS::TrueValue());
38683869
}
38693870

0 commit comments

Comments
 (0)