librpc/rpc: use dcerpc_binding_set_string_option(b, "endpoint", NULL) to reset the...
authorStefan Metzmacher <metze@samba.org>
Tue, 18 Mar 2014 06:07:13 +0000 (07:07 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 24 Mar 2014 23:45:28 +0000 (00:45 +0100)
We should always go through just one code path to [re]set a value.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/rpc/binding.c

index 90787655bbcc770a8518e339812652d094f955c5..c94bb838213d3d04b463fae879b8425fbff65465 100644 (file)
@@ -532,7 +532,7 @@ _PUBLIC_ enum dcerpc_transport_t dcerpc_binding_get_transport(const struct dcerp
 _PUBLIC_ NTSTATUS dcerpc_binding_set_transport(struct dcerpc_binding *b,
                                               enum dcerpc_transport_t transport)
 {
-       char *tmp = discard_const_p(char, b->endpoint);
+       NTSTATUS status;
 
        /*
         * TODO: we may want to check the transport value is
@@ -542,8 +542,6 @@ _PUBLIC_ NTSTATUS dcerpc_binding_set_transport(struct dcerpc_binding *b,
                return NT_STATUS_OK;
        }
 
-       b->transport = transport;
-
        /*
         * This implicitly resets the endpoint
         * as the endpoint is transport specific.
@@ -554,11 +552,14 @@ _PUBLIC_ NTSTATUS dcerpc_binding_set_transport(struct dcerpc_binding *b,
         * TODO: in future we may reset more options
         * here.
         */
-       talloc_free(tmp);
-       b->endpoint = NULL;
+       status = dcerpc_binding_set_string_option(b, "endpoint", NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        b->assoc_group_id = 0;
 
+       b->transport = transport;
        return NT_STATUS_OK;
 }