_PUBLIC_ char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
{
- char *ret;
- DATA_BLOB guid_blob;
- TALLOC_CTX *tmp_mem;
+ char *ret = NULL;
+ DATA_BLOB guid_blob = { .data = NULL };
NTSTATUS status;
- tmp_mem = talloc_new(mem_ctx);
- if (!tmp_mem) {
- return NULL;
+ status = GUID_to_ndr_blob(guid, mem_ctx, &guid_blob);
+ if (NT_STATUS_IS_OK(status)) {
+ ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
}
- status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(tmp_mem);
- return NULL;
- }
-
- ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
- talloc_free(tmp_mem);
+ TALLOC_FREE(guid_blob.data);
return ret;
}