Skip to content

Commit a4484a6

Browse files
committed
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
1 parent 1fcf62e commit a4484a6

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

contrib/jsonb_plpython/jsonb_plpython.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ PLyNumber_ToJsonbValue(PyObject *obj, JsonbValue *jbvNum)
413413
static JsonbValue *
414414
PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_elem)
415415
{
416-
JsonbValue buf;
417416
JsonbValue *out;
418417

419418
if (!(PyString_Check(obj) || PyUnicode_Check(obj)))
@@ -424,11 +423,7 @@ PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_ele
424423
return PLyMapping_ToJsonbValue(obj, jsonb_state);
425424
}
426425

427-
/* Allocate JsonbValue in heap only if it is raw scalar value. */
428-
if (*jsonb_state)
429-
out = &buf;
430-
else
431-
out = palloc(sizeof(JsonbValue));
426+
out = palloc(sizeof(JsonbValue));
432427

433428
if (obj == Py_None)
434429
out->type = jbvNull;

0 commit comments

Comments
 (0)