diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-01-30 18:25:55 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-01-30 18:26:13 -0500 |
commit | a4484a6489291d3160767d57ab538f1de6698c21 (patch) | |
tree | 6b4070cf5c2add33ac483c776b42aaaa2e3cf501 /contrib/jsonb_plpython/jsonb_plpython.c | |
parent | 1fcf62e0b837c1b814a86f3abf92ad4d36ca30e6 (diff) | |
download | postgresql-a4484a6489291d3160767d57ab538f1de6698c21.tar.gz postgresql-a4484a6489291d3160767d57ab538f1de6698c21.zip |
In jsonb_plpython.c, suppress warning message from gcc 10.
Very recent gcc complains that PLyObject_ToJsonbValue could return
a pointer to a local variable. I think it's wrong; but the coding
is fragile enough, and the savings of one palloc() minimal enough,
that it seems better to just do a palloc() all the time. (My other
idea of tweaking the if-condition doesn't suppress the warning.)
Back-patch to v11 where this code was introduced.
Discussion: https://postgr.es/m/21547.1580170366@sss.pgh.pa.us
Diffstat (limited to 'contrib/jsonb_plpython/jsonb_plpython.c')
-rw-r--r-- | contrib/jsonb_plpython/jsonb_plpython.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/contrib/jsonb_plpython/jsonb_plpython.c b/contrib/jsonb_plpython/jsonb_plpython.c index 776cf7c8b9b..8f3389aa7cd 100644 --- a/contrib/jsonb_plpython/jsonb_plpython.c +++ b/contrib/jsonb_plpython/jsonb_plpython.c @@ -413,7 +413,6 @@ PLyNumber_ToJsonbValue(PyObject *obj, JsonbValue *jbvNum) static JsonbValue * PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_elem) { - JsonbValue buf; JsonbValue *out; if (!(PyString_Check(obj) || PyUnicode_Check(obj))) @@ -424,11 +423,7 @@ PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_ele return PLyMapping_ToJsonbValue(obj, jsonb_state); } - /* Allocate JsonbValue in heap only if it is raw scalar value. */ - if (*jsonb_state) - out = &buf; - else - out = palloc(sizeof(JsonbValue)); + out = palloc(sizeof(JsonbValue)); if (obj == Py_None) out->type = jbvNull; |