Miro Kuratczyk 7 лет назад
Родитель
Сommit
9f8dae964d
1 измененных файлов с 2 добавлено и 15 удалено
  1. 2 15
      ClientLibrary/PsiphonTunnel.go

+ 2 - 15
ClientLibrary/PsiphonTunnel.go

@@ -111,8 +111,6 @@ var managedStartResult *C.char
 //   iOS:
 //     - https://github.com/Psiphon-Labs/psiphon-tunnel-core/blob/3d344194d21b250e0f18ededa4b4459a373b0690/MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m#L1105
 func psiphon_tunnel_start(cConfigJSON, cEmbeddedServerEntryList, cClientPlatform, cNetworkID *C.char, timeout int64) *C.char {
-	// NOTE: all arguments which are still referenced once Start returns should be copied onto the Go heap
-	//       to ensure that they don't disappear later on and cause Go to crash.
 
 	configJSON := C.GoString(cConfigJSON)
 	embeddedServerEntryList := C.GoString(cEmbeddedServerEntryList)
@@ -128,17 +126,11 @@ func psiphon_tunnel_start(cConfigJSON, cEmbeddedServerEntryList, cClientPlatform
 
 	// Set network ID
 
-	if networkID != "" {
-		// Ensure config.NetworkID is on the Go heap
-		config.NetworkID = deepCopy(networkID)
-	}
+	config.NetworkID = networkID
 
 	// Set client platform
 
-	if clientPlatform != "" {
-		// Ensure config.ClientPlatform is on the Go heap
-		config.ClientPlatform = deepCopy(clientPlatform)
-	}
+	config.ClientPlatform = clientPlatform
 
 	// All config fields should be set before calling commit
 	err = config.Commit()
@@ -324,11 +316,6 @@ func startErrorJson(err error) *C.char {
 	return marshalStartResult(result)
 }
 
-// deepCopy copies a string's underlying buffer and returns a new string which references the new buffer.
-func deepCopy(s string) string {
-	return string([]byte(s))
-}
-
 // freeManagedStartResult frees the memory on the heap pointed to by managedStartResult.
 func freeManagedStartResult() {
 	if managedStartResult != nil {