Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2, darwin] Make sure to copy the uri during processURLRequest #1668

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions v2/internal/frontend/desktop/darwin/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,9 @@ func (f *Frontend) ExecJS(js string) {
}

func (f *Frontend) processRequest(r *request) {
uri := C.GoString(r.url)

rw := httptest.NewRecorder()
f.assets.ProcessHTTPRequest(
uri,
r.url,
rw,
func() (*http.Request, error) {
req, err := r.GetHttpRequest()
Expand Down Expand Up @@ -352,7 +350,9 @@ func (f *Frontend) processRequest(r *request) {
headersLen = len(headerData)
}

C.ProcessURLResponse(r.ctx, r.url, C.int(rw.Code), headers, C.int(headersLen), content, C.int(contentLen))
url := C.CString(r.url)
defer C.free(unsafe.Pointer(url))
leaanthony marked this conversation as resolved.
Show resolved Hide resolved
C.ProcessURLResponse(r.ctx, url, C.int(rw.Code), headers, C.int(headersLen), content, C.int(contentLen))
}

//func (f *Frontend) processSystemEvent(message string) {
Expand All @@ -372,7 +372,7 @@ func (f *Frontend) processRequest(r *request) {
//}

type request struct {
url *C.char
url string
method string
headers string
body []byte
Expand All @@ -386,7 +386,7 @@ func (r *request) GetHttpRequest() (*http.Request, error) {
body = bytes.NewReader(r.body)
}

req, err := http.NewRequest(r.method, C.GoString(r.url), body)
req, err := http.NewRequest(r.method, r.url, body)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -419,7 +419,7 @@ func processURLRequest(ctx unsafe.Pointer, url *C.char, method *C.char, headers
}

requestBuffer <- &request{
url: url,
url: C.GoString(url),
method: C.GoString(method),
headers: C.GoString(headers),
body: goBody,
Expand Down