diff options
author | Volker Lendecke <vl@samba.org> | 2021-03-15 17:45:32 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2021-03-19 07:09:37 +0000 |
commit | 55dba99895f0e3ef9b3553e24b75b7575ce0fbc3 (patch) | |
tree | 45b20aa2ec7d6a8ae8a2f9112688ca1c591c2a9a /librpc | |
parent | 2c6bd3c6ab2e59e33a3703948ae31648212090fe (diff) | |
download | samba-55dba99895f0e3ef9b3553e24b75b7575ce0fbc3.tar.gz |
librpc: Simplify dcerpc_binding_dup() with common nomem handling
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r-- | librpc/rpc/binding.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c index 817498d8700..6588f43cc9d 100644 --- a/librpc/rpc/binding.c +++ b/librpc/rpc/binding.c @@ -1369,39 +1369,34 @@ _PUBLIC_ struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx, if (b->object_string != NULL) { n->object_string = talloc_strdup(n, b->object_string); if (n->object_string == NULL) { - talloc_free(n); - return NULL; + goto nomem; } } if (b->host != NULL) { n->host = talloc_strdup(n, b->host); if (n->host == NULL) { - talloc_free(n); - return NULL; + goto nomem; } } if (b->target_hostname != NULL) { n->target_hostname = talloc_strdup(n, b->target_hostname); if (n->target_hostname == NULL) { - talloc_free(n); - return NULL; + goto nomem; } } if (b->target_principal != NULL) { n->target_principal = talloc_strdup(n, b->target_principal); if (n->target_principal == NULL) { - talloc_free(n); - return NULL; + goto nomem; } } if (b->endpoint != NULL) { n->endpoint = talloc_strdup(n, b->endpoint); if (n->endpoint == NULL) { - talloc_free(n); - return NULL; + goto nomem; } } @@ -1412,21 +1407,22 @@ _PUBLIC_ struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx, n->options = talloc_array(n, const char *, count + 1); if (n->options == NULL) { - talloc_free(n); - return NULL; + goto nomem; } for (i = 0; i < count; i++) { n->options[i] = talloc_strdup(n->options, b->options[i]); if (n->options[i] == NULL) { - talloc_free(n); - return NULL; + goto nomem; } } n->options[count] = NULL; } return n; +nomem: + TALLOC_FREE(n); + return NULL; } _PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, |