Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a069218

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 74618e7 commit a069218

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

contrib/jsonb_plpython/jsonb_plpython.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ PLyNumber_ToJsonbValue(PyObject *obj, JsonbValue *jbvNum)
410410
static JsonbValue *
411411
PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_elem)
412412
{
413-
JsonbValue buf;
414413
JsonbValue *out;
415414

416415
if (!(PyString_Check(obj) || PyUnicode_Check(obj)))
@@ -421,11 +420,7 @@ PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_ele
421420
return PLyMapping_ToJsonbValue(obj, jsonb_state);
422421
}
423422

424-
/* Allocate JsonbValue in heap only if it is raw scalar value. */
425-
if (*jsonb_state)
426-
out = &buf;
427-
else
428-
out = palloc(sizeof(JsonbValue));
423+
out = palloc(sizeof(JsonbValue));
429424

430425
if (obj == Py_None)
431426
out->type = jbvNull;

0 commit comments

Comments
 (0)