From: Volker Lendecke Date: Thu, 12 Sep 2024 14:18:57 +0000 (+0200) Subject: libndr: Use TALLOC_FREE instead of talloc_free X-Git-Tag: tdb-1.4.13~1193 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d4a7a448e131203d6e05796d088d8572dee88d8;p=thirdparty%2Fsamba.git libndr: Use TALLOC_FREE instead of talloc_free All the existing calls are right before returns, so they don't really matter. But you never know when the code will change, and any compiler will wipe the NULL assignment. Signed-off-by: Volker Lendecke Reviewed-by: Noel Power --- diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 61e660550eb..21c71f1a022 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -478,7 +478,7 @@ enum ndr_compression_alg { enum ndr_err_code _status; \ _status = call; \ if (unlikely(!NDR_ERR_CODE_IS_SUCCESS(_status))) { \ - talloc_free(ndr); \ + TALLOC_FREE(ndr); \ return _status; \ } \ } while (0) diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c index d3494c54e71..1916b6db7b8 100644 --- a/librpc/ndr/ndr.c +++ b/librpc/ndr/ndr.c @@ -238,7 +238,7 @@ _PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx) ndr->alloc_size = NDR_BASE_MARSHALL_SIZE; ndr->data = talloc_array(ndr, uint8_t, ndr->alloc_size); if (!ndr->data) { - talloc_free(ndr); + TALLOC_FREE(ndr); return NULL; } @@ -425,7 +425,7 @@ _PUBLIC_ void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *na #endif fn(ndr, name, ptr); - talloc_free(ndr); + TALLOC_FREE(ndr); } /* @@ -461,7 +461,7 @@ _PUBLIC_ bool ndr_print_debug(int level, ret = true; fail: - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } @@ -487,7 +487,7 @@ _PUBLIC_ void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_ ndr_print_set_switch_value(ndr, ptr, level); fn(ndr, name, ptr); - talloc_free(ndr); + TALLOC_FREE(ndr); } /* @@ -511,7 +511,7 @@ _PUBLIC_ void ndr_print_function_debug(ndr_print_function_t fn, const char *name #endif fn(ndr, name, flags, ptr); - talloc_free(ndr); + TALLOC_FREE(ndr); } /* @@ -535,7 +535,7 @@ _PUBLIC_ char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, c fn(ndr, name, ptr); ret = talloc_steal(mem_ctx, (char *)ndr->private_data); failed: - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } @@ -560,7 +560,7 @@ _PUBLIC_ char *ndr_print_union_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, co fn(ndr, name, ptr); ret = talloc_steal(mem_ctx, (char *)ndr->private_data); failed: - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } @@ -586,7 +586,7 @@ _PUBLIC_ char *ndr_print_function_string(TALLOC_CTX *mem_ctx, fn(ndr, name, flags, ptr); ret = talloc_steal(mem_ctx, (char *)ndr->private_data); failed: - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } @@ -901,7 +901,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_start(struct ndr_push *ndr, status = ndr_push_zero(subndr, size_is); if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(subndr); + TALLOC_FREE(subndr); return status; } subndr->offset = 0; @@ -1337,7 +1337,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CT ndr = ndr_pull_init_blob(blob, mem_ctx); NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - talloc_free(ndr); + TALLOC_FREE(ndr); return NDR_ERR_SUCCESS; } @@ -1362,10 +1362,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES, "not all bytes consumed ofs[%"PRIu32"] size[%"PRIu32"]", highest_ofs, ndr->data_size); - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } - talloc_free(ndr); + TALLOC_FREE(ndr); return NDR_ERR_SUCCESS; } @@ -1446,7 +1446,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level)); NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); - talloc_free(ndr); + TALLOC_FREE(ndr); return NDR_ERR_SUCCESS; } @@ -1474,10 +1474,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES, "not all bytes consumed ofs[%"PRIu32"] size[%"PRIu32"]", highest_ofs, ndr->data_size); - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } - talloc_free(ndr); + TALLOC_FREE(ndr); return NDR_ERR_SUCCESS; } @@ -1494,7 +1494,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem *blob = ndr_push_blob(ndr); talloc_steal(mem_ctx, blob->data); - talloc_free(ndr); + TALLOC_FREE(ndr); return NDR_ERR_SUCCESS; } @@ -1543,7 +1543,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ *blob = ndr_push_blob(ndr); talloc_steal(mem_ctx, blob->data); - talloc_free(ndr); + TALLOC_FREE(ndr); return NDR_ERR_SUCCESS; } @@ -1570,11 +1570,11 @@ _PUBLIC_ size_t ndr_size_struct(const void *p, libndr_flags flags, ndr_push_flag ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE; status = push(ndr, NDR_SCALARS|NDR_BUFFERS, discard_const(p)); if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(ndr); + TALLOC_FREE(ndr); return 0; } ret = ndr->offset; - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } @@ -1601,16 +1601,16 @@ _PUBLIC_ size_t ndr_size_union(const void *p, libndr_flags flags, uint32_t level status = ndr_push_set_switch_value(ndr, p, level); if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(ndr); + TALLOC_FREE(ndr); return 0; } status = push(ndr, NDR_SCALARS|NDR_BUFFERS, p); if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(ndr); + TALLOC_FREE(ndr); return 0; } ret = ndr->offset; - talloc_free(ndr); + TALLOC_FREE(ndr); return ret; } diff --git a/librpc/ndr/ndr_cab.c b/librpc/ndr/ndr_cab.c index ae3353bc25c..7b78a7df6c2 100644 --- a/librpc/ndr/ndr_cab.c +++ b/librpc/ndr/ndr_cab.c @@ -36,7 +36,7 @@ _PUBLIC_ void ndr_print_cf_time(struct ndr_print *ndr, const char *name, const s s = talloc_asprintf(ndr, "%02d:%02d:%02d", hour, minute, seconds); if (s == NULL) { return; } ndr_print_string(ndr, "time", s); - talloc_free(s); + TALLOC_FREE(s); } _PUBLIC_ void ndr_print_cf_date(struct ndr_print *ndr, const char *name, const struct cf_date *r) @@ -52,7 +52,7 @@ _PUBLIC_ void ndr_print_cf_date(struct ndr_print *ndr, const char *name, const s s = talloc_asprintf(ndr, "%02"PRIu8"/%02"PRIu8"/%04"PRIu16, day, month, year); if (s == NULL) { return; } ndr_print_string(ndr, "date", s); - talloc_free(s); + TALLOC_FREE(s); } uint32_t ndr_count_cfdata(const struct cab_file *r) diff --git a/librpc/ndr/ndr_compression.c b/librpc/ndr/ndr_compression.c index 04d810a5cb3..fb52bc81e88 100644 --- a/librpc/ndr/ndr_compression.c +++ b/librpc/ndr/ndr_compression.c @@ -48,7 +48,7 @@ static voidpf ndr_zlib_alloc(voidpf opaque, uInt items, uInt size) static void ndr_zlib_free(voidpf opaque, voidpf address) { - talloc_free(address); + TALLOC_FREE(address); } static enum ndr_err_code ndr_pull_compression_mszip_cab_chunk(struct ndr_pull *ndrpull, @@ -974,7 +974,7 @@ enum ndr_err_code ndr_push_compression_end(struct ndr_push *subndr, compression_alg); } - talloc_free(uncomndr); + TALLOC_FREE(uncomndr); return NDR_ERR_SUCCESS; } diff --git a/librpc/ndr/ndr_drsblobs.c b/librpc/ndr/ndr_drsblobs.c index b6eea1757d0..ad4af4f338d 100644 --- a/librpc/ndr/ndr_drsblobs.c +++ b/librpc/ndr/ndr_drsblobs.c @@ -142,8 +142,8 @@ _PUBLIC_ void ndr_print_drsuapi_MSPrefixMap_Entry(struct ndr_print *ndr, const c ndr->depth++; ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid); ndr->depth--; - talloc_free(hex_str); - talloc_free(partial_oid); + TALLOC_FREE(hex_str); + TALLOC_FREE(partial_oid); } ndr->depth--; ndr->flags = _flags_save_STRUCT; diff --git a/librpc/ndr/ndr_drsuapi.c b/librpc/ndr/ndr_drsuapi.c index 63d1d74b6e8..787347fbf4d 100644 --- a/librpc/ndr/ndr_drsuapi.c +++ b/librpc/ndr/ndr_drsuapi.c @@ -81,8 +81,8 @@ _PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char * ndr->depth++; ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid); ndr->depth--; - talloc_free(hex_str); - talloc_free(partial_oid); + TALLOC_FREE(hex_str); + TALLOC_FREE(partial_oid); } ndr->depth--; } @@ -125,7 +125,7 @@ static void _print_drsuapi_DsAttributeValue_str(struct ndr_print *ndr, const cha } else { char *str = (char *)p; ndr_print_string(ndr, "string", str); - talloc_free(str); + TALLOC_FREE(str); } ndr->depth--; } @@ -223,7 +223,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed)); } compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); + TALLOC_FREE(_ndr_ts); } } NDR_CHECK(ndr_push_align(ndr, 4)); @@ -268,7 +268,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed)); } compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); + TALLOC_FREE(_ndr_ts); } } NDR_CHECK(ndr_push_align(ndr, 4)); @@ -313,7 +313,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesWIN2K3_LZ77_DIRECT2Ctr1(struct NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed)); } compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); + TALLOC_FREE(_ndr_ts); } } NDR_CHECK(ndr_push_align(ndr, 4)); @@ -358,7 +358,7 @@ enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesWIN2K3_LZ77_DIRECT2Ctr6(struct NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed)); } compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); + TALLOC_FREE(_ndr_ts); } } NDR_CHECK(ndr_push_align(ndr, 4)); diff --git a/librpc/ndr/ndr_sec_helper.c b/librpc/ndr/ndr_sec_helper.c index 028d11c2a83..7f95f1423d7 100644 --- a/librpc/ndr/ndr_sec_helper.c +++ b/librpc/ndr/ndr_sec_helper.c @@ -336,7 +336,7 @@ enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, ndr_flags_type ndr_fl status = ndr_pull_advance(ndr, 28); if (!NDR_ERR_CODE_IS_SUCCESS(status)) { - talloc_free(subndr); + TALLOC_FREE(subndr); return status; } @@ -348,7 +348,7 @@ enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, ndr_flags_type ndr_fl ZERO_STRUCT(sid->sub_auths); } - talloc_free(subndr); + TALLOC_FREE(subndr); return NDR_ERR_SUCCESS; } diff --git a/librpc/ndr/ndr_spoolss_buf.c b/librpc/ndr/ndr_spoolss_buf.c index abeb8847f37..60579893c4a 100644 --- a/librpc/ndr/ndr_spoolss_buf.c +++ b/librpc/ndr/ndr_spoolss_buf.c @@ -1579,7 +1579,7 @@ _PUBLIC_ void ndr_print_spoolss_Time(struct ndr_print *ndr, const char *name, co ndr->depth++; ndr_print_string(ndr, "", str); ndr->depth--; - talloc_free(str); + TALLOC_FREE(str); } _PUBLIC_ libndr_flags ndr_spoolss_PrinterEnumValues_align(enum winreg_Type type) diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c index 323886b2fe5..96272d679c0 100644 --- a/librpc/ndr/ndr_string.c +++ b/librpc/ndr/ndr_string.c @@ -419,7 +419,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, ndr_flags_type } out: - talloc_free(dest_to_free); + TALLOC_FREE(dest_to_free); return ndr_err; }