From: Volker Lendecke Date: Mon, 14 Oct 2024 11:29:21 +0000 (+0200) Subject: libcli: avoid work in security token debug no-op X-Git-Tag: tevent-0.17.0~616 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b25e63710eb247a03cc2da99f44eace6cda2c50d;p=thirdparty%2Fsamba.git libcli: avoid work in security token debug no-op When the debug level is too low to print, we don't need to allocate the strings. Bug: https://bugzilla.samba.org/show_bug.cgi?id=15737 Signed-off-by: Volker Lendecke Signed-off-by: Douglas Bagnall Reviewed-by: Jennifer Sutton Pair-programmed-with: Douglas Bagnall --- diff --git a/libcli/security/security_token.c b/libcli/security/security_token.c index 0218eed1722..a79f5925ea2 100644 --- a/libcli/security/security_token.c +++ b/libcli/security/security_token.c @@ -80,17 +80,22 @@ struct security_token *security_token_duplicate(TALLOC_CTX *mem_ctx, const struc ****************************************************************************/ void security_token_debug(int dbg_class, int dbg_lev, const struct security_token *token) { - TALLOC_CTX *frame = talloc_stackframe(); + TALLOC_CTX *frame = NULL; char *sids = NULL; char *privs = NULL; uint32_t i; + if (!CHECK_DEBUGLVLC(dbg_class, dbg_lev)) { + return; + } + if (!token) { DEBUGC(dbg_class, dbg_lev, ("Security token: (NULL)\n")); - TALLOC_FREE(frame); return; } + frame = talloc_stackframe(); + sids = talloc_asprintf(frame, "Security token SIDs (%" PRIu32 "):\n", token->num_sids);