]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_server: Introduce "goto nomem;" to dcesrv_endpoint_connect()
authorVolker Lendecke <vl@samba.org>
Wed, 20 Jan 2021 13:30:57 +0000 (14:30 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 28 Jan 2021 16:58:35 +0000 (16:58 +0000)
Avoid the control-flow changing NT_STATUS_HAVE_NO_MEMORY macro.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
librpc/rpc/dcesrv_core.c

index a413359d985ac838502fd518a0481d2b409c2ed8..ccfc01a57d9c997fba2f4565c5441a4153789834 100644 (file)
@@ -533,14 +533,16 @@ _PUBLIC_ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
                                struct dcesrv_connection **_p)
 {
        struct dcesrv_auth *auth = NULL;
-       struct dcesrv_connection *p;
+       struct dcesrv_connection *p = NULL;
 
        if (!session_info) {
                return NT_STATUS_ACCESS_DENIED;
        }
 
        p = talloc_zero(mem_ctx, struct dcesrv_connection);
-       NT_STATUS_HAVE_NO_MEMORY(p);
+       if (p == NULL) {
+               goto nomem;
+       }
 
        p->dce_ctx = dce_ctx;
        p->endpoint = ep;
@@ -568,14 +570,12 @@ _PUBLIC_ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
 
        auth = dcesrv_auth_create(p);
        if (auth == NULL) {
-               talloc_free(p);
-               return NT_STATUS_NO_MEMORY;
+               goto nomem;
        }
 
        auth->session_info = talloc_reference(auth, session_info);
        if (auth->session_info == NULL) {
-               talloc_free(p);
-               return NT_STATUS_NO_MEMORY;
+               goto nomem;
        }
 
        p->default_auth_state = auth;
@@ -587,6 +587,9 @@ _PUBLIC_ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
 
        *_p = p;
        return NT_STATUS_OK;
+nomem:
+       TALLOC_FREE(p);
+       return NT_STATUS_NO_MEMORY;
 }
 
 /*