[v2, darwin] Initialize native variables on stack to prevent segfault (#1362)

This commit is contained in:
stffabi
2022-04-30 06:11:19 +10:00
committed by GitHub
parent d9120181b7
commit 22d3f93b52
2 changed files with 3 additions and 3 deletions
@@ -397,8 +397,8 @@
const char *url = [urlSchemeTask.request.URL.absoluteString UTF8String];
const char *method = [urlSchemeTask.request.HTTPMethod UTF8String];
const char *headerJSON = "";
const void *body;
int bodyLen;
const void *body = nil;
int bodyLen = 0;
NSData *headers = [NSJSONSerialization dataWithJSONObject: urlSchemeTask.request.allHTTPHeaderFields options:0 error: nil];
if (headers) {
@@ -396,7 +396,7 @@ func processMessage(message *C.char) {
//export processURLRequest
func processURLRequest(ctx unsafe.Pointer, url *C.char, method *C.char, headers *C.char, body unsafe.Pointer, bodyLen C.int) {
var goBody []byte
if bodyLen != 0 {
if body != nil && bodyLen != 0 {
goBody = C.GoBytes(body, bodyLen)
}