From: Andrew Tridgell Date: Fri, 16 Oct 2009 06:04:19 +0000 (+1100) Subject: added NT_STATUS_NOT_OK_RETURN_AND_FREE() X-Git-Tag: tdb-1.2.0~688^2~18 X-Git-Url: http://git.samba.org/samba.git/?p=ira%2Fwip.git;a=commitdiff_plain;h=b6a1beb13139a6aa89ac1d4bb201a9c9d1453262 added NT_STATUS_NOT_OK_RETURN_AND_FREE() Try to make it a bit easier to avoid leaks in common code --- diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h index 1025f472104..88b4353c1d1 100644 --- a/libcli/util/ntstatus.h +++ b/libcli/util/ntstatus.h @@ -674,6 +674,13 @@ extern bool ntstatus_check_dos_mapping; }\ } while (0) +#define NT_STATUS_NOT_OK_RETURN_AND_FREE(x, ctx) do { \ + if (!NT_STATUS_IS_OK(x)) {\ + talloc_free(ctx); \ + return x;\ + }\ +} while (0) + #define NT_STATUS_IS_ERR_RETURN(x) do { \ if (NT_STATUS_IS_ERR(x)) {\ return x;\