From b96aac3d0aed234bf06d3ebdc53b6ccec44aee4a Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Wed, 12 Jun 2024 12:40:35 +0200 Subject: [PATCH] Avoid needless reallocation of host & port strings on iOS This is also extremely likely a memory leak since we're never cleaning these up - best to avoid that! --- ios/ios-connect-hook.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/ios-connect-hook.js b/ios/ios-connect-hook.js index 8ead832..8459df6 100644 --- a/ios/ios-connect-hook.js +++ b/ios/ios-connect-hook.js @@ -29,11 +29,11 @@ const nw_endpoint_create_host = new NativeFunction( 'pointer', ['pointer', 'pointer'] ); +const newHostStr = Memory.allocUtf8String(PROXY_HOST); +const newPortStr = Memory.allocUtf8String(PROXY_PORT.toString()); + Interceptor.attach(nw_connection_create, { onEnter: function (args) { - const newHostStr = Memory.allocUtf8String(PROXY_HOST); - const newPortStr = Memory.allocUtf8String(PROXY_PORT.toString()); - // Replace the endpoint argument entirely with our own: args[0] = nw_endpoint_create_host(newHostStr, newPortStr); }