From 182b31f902fdb4e23d2fda29273686e9e310999f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 24 Oct 2026 15:40:31 +0200 Subject: [PATCH] Mark Infer's null dereference in materialize() as a false positive Infer (ci_infer, also red on develop since #5882) reports a null dereference in json_sax_dom_parser::null() called from materialize(). The member pointer the parser stores a value of an object in is set by the key() before it, so it is not null there. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/materialize.hpp | 3 +++ single_include/nlohmann/json_view.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/nlohmann/detail/view/materialize.hpp b/include/nlohmann/detail/view/materialize.hpp index 006bdd0f3..931594219 100644 --- a/include/nlohmann/detail/view/materialize.hpp +++ b/include/nlohmann/detail/view/materialize.hpp @@ -143,6 +143,9 @@ BasicJsonType materialize(const document_data& d, const node* n) case value_t::binary: case value_t::discarded: default: + // false positive: a value in an object follows its key(), which set the + // member the parser stores it in + // @infer-ignore NULLPTR_DEREFERENCE sax.null(); break; } diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 39dd413ec..47d28ca0c 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -7185,6 +7185,9 @@ BasicJsonType materialize(const document_data& d, const node* n) case value_t::binary: case value_t::discarded: default: + // false positive: a value in an object follows its key(), which set the + // member the parser stores it in + // @infer-ignore NULLPTR_DEREFERENCE sax.null(); break; }