From 8f185c87f79b589011d83cea39d83933640d4918 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 2 Oct 2026 11:44:12 +0200 Subject: [PATCH] Mark an Infer false positive in materialize() Infer 1.3.0 reports NULLPTR_DEREFERENCE because the node pointer can come from navigation::value(), which follows links. A link always has a target in a valid index, so suppress it on that line, as develop does for its own Infer false positives (#5750). Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/materialize.hpp | 2 ++ single_include/nlohmann/json_view.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/nlohmann/detail/view/materialize.hpp b/include/nlohmann/detail/view/materialize.hpp index f9c381e1a..008b30ba8 100644 --- a/include/nlohmann/detail/view/materialize.hpp +++ b/include/nlohmann/detail/view/materialize.hpp @@ -54,6 +54,8 @@ BasicJsonType materialize(const document_data& d, const node* n) std::vector open; for (;;) { + // false positive: n comes from nav::value(), which never returns null for a valid index + // @infer-ignore NULLPTR_DEREFERENCE switch (static_cast(n->kind)) { case value_t::object: diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 653a3cc65..92f98a8df 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -4326,6 +4326,8 @@ BasicJsonType materialize(const document_data& d, const node* n) std::vector open; for (;;) { + // false positive: n comes from nav::value(), which never returns null for a valid index + // @infer-ignore NULLPTR_DEREFERENCE switch (static_cast(n->kind)) { case value_t::object: