Skip to content

Commit c77f218

Browse files
committed
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
1 parent d4b754c commit c77f218

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

contrib/hstore_plpython/hstore_plpython.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Datum
124124
plpython_to_hstore(PG_FUNCTION_ARGS)
125125
{
126126
PyObject *dict;
127-
volatile PyObject *items_v = NULL;
127+
PyObject *volatile items = NULL;
128128
int32 pcount;
129129
HStore *out;
130130

@@ -135,14 +135,13 @@ plpython_to_hstore(PG_FUNCTION_ARGS)
135135
errmsg("not a Python mapping")));
136136

137137
pcount = PyMapping_Size(dict);
138-
items_v = PyMapping_Items(dict);
138+
items = PyMapping_Items(dict);
139139

140140
PG_TRY();
141141
{
142142
int32 buflen;
143143
int32 i;
144144
Pairs *pairs;
145-
PyObject *items = (PyObject *) items_v;
146145

147146
pairs = palloc(pcount * sizeof(*pairs));
148147

@@ -173,14 +172,14 @@ plpython_to_hstore(PG_FUNCTION_ARGS)
173172
pairs[i].isnull = false;
174173
}
175174
}
176-
Py_DECREF(items_v);
175+
Py_DECREF(items);
177176

178177
pcount = hstoreUniquePairs(pairs, pcount, &buflen);
179178
out = hstorePairs(pairs, pcount, buflen);
180179
}
181180
PG_CATCH();
182181
{
183-
Py_DECREF(items_v);
182+
Py_DECREF(items);
184183
PG_RE_THROW();
185184
}
186185
PG_END_TRY();

0 commit comments

Comments
 (0)