postgres.git / summary / log / commit / refs

commit    c77f21899ac2bd85d9d30d2dbf60904498ebee2f
Author:   Peter Eisentraut <peter@eisentraut.org>
Date:     Thu Mar 14 07:25:25 2019 +0000
First released in: 12.0, 9.5.17, 9.6.13, 10.8, 11.3

    Fix volatile vs. pointer confusion
    
    Variables used after a longjmp() need to be declared volatile.  In
    case of a pointer, it's the pointer itself that needs to be declared
    volatile, not the pointed-to value.  So we need
    
        PyObject *volatile items;
    
    instead of
    
        volatile PyObject *items;  /* wrong */
    
    Discussion: https://www.postgresql.org/message-id/flat/f747368d-9e1a-c46a-ac76-3c27da32e8e4%402ndquadrant.com


contrib/hstore_plpython/hstore_plpython.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/contrib/hstore_plpython/hstore_plpython.c b/contrib/hstore_plpython/hstore_plpython.c index b184324ebf0..25328322364 100644 --- a/contrib/hstore_plpython/hstore_plpython.c +++ b/contrib/hstore_plpython/hstore_plpython.c @@ -124,7 +124,7 @@ Datum plpython_to_hstore(PG_FUNCTION_ARGS) { PyObject *dict; - volatile PyObject *items_v = NULL; + PyObject *volatile items = NULL; int32 pcount; HStore *out; @@ -135,14 +135,13 @@ plpython_to_hstore(PG_FUNCTION_ARGS) errmsg("not a Python mapping"))); pcount = PyMapping_Size(dict); - items_v = PyMapping_Items(dict); + items = PyMapping_Items(dict); PG_TRY(); { int32 buflen; int32 i; Pairs *pairs; - PyObject *items = (PyObject *) items_v; pairs = palloc(pcount * sizeof(*pairs)); @@ -173,14 +172,14 @@ plpython_to_hstore(PG_FUNCTION_ARGS) pairs[i].isnull = false; } } - Py_DECREF(items_v); + Py_DECREF(items); pcount = hstoreUniquePairs(pairs, pcount, &buflen); out = hstorePairs(pairs, pcount, buflen); } PG_CATCH(); { - Py_DECREF(items_v); + Py_DECREF(items); PG_RE_THROW(); } PG_END_TRY(); [parent: d4b754c876d3]