aboutsummaryrefslogtreecommitdiff
path: root/contrib/hstore_plpython
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2019-03-14 08:25:25 +0100
committerPeter Eisentraut <peter@eisentraut.org>2019-03-14 08:42:48 +0100
commit1226d932b4dadc39ba2f9a488e4d784443ea6a78 (patch)
tree9e6bb1e68733905d5deb4cd27836a8db6228d84f /contrib/hstore_plpython
parent6eebfdc38b173edcd179f422cf7083383edb24bc (diff)
downloadpostgresql-1226d932b4dadc39ba2f9a488e4d784443ea6a78.tar.gz
postgresql-1226d932b4dadc39ba2f9a488e4d784443ea6a78.zip
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
Diffstat (limited to 'contrib/hstore_plpython')
-rw-r--r--contrib/hstore_plpython/hstore_plpython.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/contrib/hstore_plpython/hstore_plpython.c b/contrib/hstore_plpython/hstore_plpython.c
index 2f24090ff3e..93c39d294dd 100644
--- a/contrib/hstore_plpython/hstore_plpython.c
+++ b/contrib/hstore_plpython/hstore_plpython.c
@@ -128,7 +128,7 @@ Datum
plpython_to_hstore(PG_FUNCTION_ARGS)
{
PyObject *dict;
- volatile PyObject *items_v = NULL;
+ PyObject *volatile items = NULL;
int32 pcount;
HStore *out;
@@ -139,14 +139,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));
@@ -177,14 +176,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();