From c8315930e6a34b616d9840985c85eb0d856dd2df Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 16 Dec 2014 10:32:06 -0500 Subject: Fix some jsonb issues found by Coverity in recent commits. Mostly these issues concern the non-use of function results. These have been changed to use (void) pushJsonbValue(...) instead of assigning the result to a variable that gets overwritten before it is used. There is a larger issue that we should possibly examine the API for pushJsonbValue(), so that instead of returning a value it modifies a state argument. The current idiom is rather clumsy. However, changing that requires quite a bit more work, so this change should do for the moment. --- src/backend/utils/adt/jsonfuncs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/adt/jsonfuncs.c') diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 0a85ee81091..93cbe274f07 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -3182,7 +3182,7 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS) continue; /* otherwise, do a delayed push of the key */ - res = pushJsonbValue(&parseState, WJB_KEY, &k); + (void) pushJsonbValue(&parseState, WJB_KEY, &k); } if (type == WJB_VALUE || type == WJB_ELEM) @@ -3191,5 +3191,7 @@ jsonb_strip_nulls(PG_FUNCTION_ARGS) res = pushJsonbValue(&parseState, type, NULL); } + Assert(res != NULL); + PG_RETURN_POINTER(JsonbValueToJsonb(res)); } -- cgit v1.2.3