]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Silence scan-build leak false positive in isccc_cc_checkdup() 12298/head
authorMichal Nowak <mnowak@isc.org>
Mon, 29 Jun 2026 12:41:03 +0000 (12:41 +0000)
committerMichal Nowak <mnowak@isc.org>
Thu, 23 Jul 2026 12:22:12 +0000 (14:22 +0200)
On success the symtab owns 'key' and frees it via symtab_undefine(), but
scan-build cannot see that ownership pass through the const key
parameter of isc_symtab_define() and reports a leak.  free(key) under
__clang_analyzer__ only, which placates the checker without affecting
real builds:

    lib/isccc/cc.c:1015:9: warning: Potential leak of memory pointed to by 'key' [unix.Malloc]

Assisted-by: Claude:claude-opus-4-8
lib/isccc/cc.c

index bb3f3530d5fdc5d55105aa7c640a8770188ef096..a08ca0ab7463fce78638a928b852192a2f2e0555 100644 (file)
@@ -1012,5 +1012,15 @@ isccc_cc_checkdup(isc_symtab_t *symtab, isccc_sexpr_t *message,
                return result;
        }
 
+#ifdef __clang_analyzer__
+       /*
+        * On success the symtab owns 'key' and frees it via
+        * symtab_undefine().  scan-build cannot see that ownership pass
+        * through the const key parameter of isc_symtab_define(), so free
+        * it here under analysis only to avoid a false-positive leak report.
+        */
+       free(key);
+#endif
+
        return ISC_R_SUCCESS;
 }