diff options
author | Tom Lane | 2020-01-30 23:25:55 +0000 |
---|---|---|
committer | Tom Lane | 2020-01-30 23:26:12 +0000 |
commit | a069218163704c44a8996e7e98e765c56e2b9c8e (patch) | |
tree | 405ddea4ac666ec667c0ad46a50d29c9b1e16ed7 /contrib/jsonb_plpython | |
parent | 74618e77b43cfce670b4725d5b9a300a2afd12d1 (diff) |
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/[email protected]
Diffstat (limited to 'contrib/jsonb_plpython')
-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 b06ad9f9291..e09308daf07 100644 --- a/contrib/jsonb_plpython/jsonb_plpython.c +++ b/contrib/jsonb_plpython/jsonb_plpython.c @@ -410,7 +410,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))) @@ -421,11 +420,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; |