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

Lines changed: 1 addition & 6 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy