From b6a1beb13139a6aa89ac1d4bb201a9c9d1453262 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 16 Oct 2009 17:04:19 +1100 Subject: added NT_STATUS_NOT_OK_RETURN_AND_FREE() Try to make it a bit easier to avoid leaks in common code --- libcli/util/ntstatus.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libcli/util') diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h index 1025f47210..88b4353c1d 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;\ -- cgit