From 2629c993cf1ef104cd343395aa45524836446577 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 19 Oct 2021 14:57:47 -0400 Subject: builder,parser: Use g_assert for sanity checks Coverity noticed a leak in json_builder_get_root that can't happen in practice. Namely, if internal state gets screwed up and runtime checks are enabled, json_builder_get_root may return NULL without freeing a copy of the builder root it just made. This is because of a g_return_val_if_fail call to bail early if an internal consistency sanity check fails. This commit addresses the coverity complaint by using g_assert instead of g_return_val_if_fail for this sanity check, and other similar sanity checks, in the code. --- json-glib/json-builder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'json-glib/json-builder.c') diff --git a/json-glib/json-builder.c b/json-glib/json-builder.c index 45f6cbe..1106ae5 100644 --- a/json-glib/json-builder.c +++ b/json-glib/json-builder.c @@ -315,9 +315,9 @@ json_builder_get_root (JsonBuilder *builder) root = json_node_copy (builder->priv->root); /* Sanity check. */ - g_return_val_if_fail (!builder->priv->immutable || - root == NULL || - json_node_is_immutable (root), NULL); + g_assert (!builder->priv->immutable || + root == NULL || + json_node_is_immutable (root)); return root; } -- cgit v1.2.1