kernel: Remove NONNULL annotation from destroy method
What changed, and why it matters
This commit removes a compiler hint telling the destroy function it must never receive a null pointer. The change makes the function behave more like standard free(), which safely accepts null. It is a defensive API-consistency fix, not a fix for an active crash or exploit.
Verify that the implementation of btck_block_validation_state_destroy actually handles a NULL argument safely (e.g., returns immediately like free()). If it does, no further action is needed. If it does not, update the implementation to match the new contract. Downstream bindings using this API should also be reviewed for any code that relied on the non-null guarantee.
Security signals we found
Removal of a nonnull compiler attribute that could have enabled UB-based optimizations if a NULL pointer were passed
API consistency change: other kernel destroy functions do not carry the annotation
No functional code change shown; only the public header contract is modified
Evidence from the diff
The commit removes the BITCOINKERNEL_ARG_NONNULL(1) attribute from btck_block_validation_state_destroy() in the public kernel C API header. With the attribute gone, callers that pass NULL will no longer trigger undefined-behavior-based compiler optimizations (e.g., eliding subsequent null checks, propagating non-null assumptions, or generating traps). The implementation’s actual null handling is not shown in the diff; the patch only changes the interface contract. It aligns the function with other *_destroy functions in the same API that lack the nonnull annotation.
Changed components
src/kernel/bitcoinkernel.hPublic Bitcoin Kernel C APIbtck_block_validation_state_destroyInspect captured patch +1 / −1
diff --git a/src/kernel/bitcoinkernel.h b/src/kernel/bitcoinkernel.h
index fe5bc3f9..a71a4de1 100644
--- a/src/kernel/bitcoinkernel.h
+++ b/src/kernel/bitcoinkernel.h
@@ -1344,7 +1344,7 @@ BITCOINKERNEL_API btck_BlockValidationState* BITCOINKERNEL_WARN_UNUSED_RESULT bt
* Destroy the btck_BlockValidationState.
*/
BITCOINKERNEL_API void btck_block_validation_state_destroy(
- btck_BlockValidationState* block_validation_state) BITCOINKERNEL_ARG_NONNULL(1);
+ btck_BlockValidationState* block_validation_state);
///@}
Why this scored 21/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.