Transfer ownership of tsi_handshaker in adapter_create_result.
diff --git a/src/core/tsi/transport_security_adapter. b/src/core/tsi/transport_security_adapter.
deleted file mode 100644
index e69de29..0000000
--- a/src/core/tsi/transport_security_adapter.
+++ /dev/null
diff --git a/src/core/tsi/transport_security_adapter.c b/src/core/tsi/transport_security_adapter.c
index d83339b..9f2147b 100644
--- a/src/core/tsi/transport_security_adapter.c
+++ b/src/core/tsi/transport_security_adapter.c
@@ -75,6 +75,7 @@
static void adapter_result_destroy(tsi_handshaker_result *self) {
tsi_adapter_handshaker_result *impl = (tsi_adapter_handshaker_result *)self;
+ tsi_handshaker_destroy(impl->wrapped);
gpr_free(impl->unused_bytes);
gpr_free(self);
}
@@ -84,7 +85,8 @@
adapter_result_get_unused_bytes, adapter_result_destroy,
};
-tsi_result tsi_adapter_create_handshaker_result(
+/* Ownership of wrapped tsi_handshaker is transferred to the result object. */
+static tsi_result tsi_adapter_create_handshaker_result(
tsi_handshaker *wrapped, const unsigned char *unused_bytes,
size_t unused_bytes_size, tsi_handshaker_result **handshaker_result) {
if (wrapped == NULL || (unused_bytes_size > 0 && unused_bytes == NULL)) {
@@ -201,6 +203,7 @@
impl->wrapped, unused_bytes, unused_bytes_size, handshaker_result);
if (status == TSI_OK) {
impl->base.handshaker_result_created = true;
+ impl->wrapped = NULL;
}
}
return status;