Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1226d93

Browse files
committed
Fix volatile vs. pointer confusion
Variables used after a longjmp() need to be declared volatile. Incase of a pointer, it's the pointer itself that needs to be declaredvolatile, 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 parent6eebfdc commit1226d93

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

‎contrib/hstore_plpython/hstore_plpython.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Datum
128128
plpython_to_hstore(PG_FUNCTION_ARGS)
129129
{
130130
PyObject*dict;
131-
volatilePyObject*items_v=NULL;
131+
PyObject*volatileitems=NULL;
132132
int32pcount;
133133
HStore*out;
134134

@@ -139,14 +139,13 @@ plpython_to_hstore(PG_FUNCTION_ARGS)
139139
errmsg("not a Python mapping")));
140140

141141
pcount=PyMapping_Size(dict);
142-
items_v=PyMapping_Items(dict);
142+
items=PyMapping_Items(dict);
143143

144144
PG_TRY();
145145
{
146146
int32buflen;
147147
int32i;
148148
Pairs*pairs;
149-
PyObject*items= (PyObject*)items_v;
150149

151150
pairs=palloc(pcount*sizeof(*pairs));
152151

@@ -177,14 +176,14 @@ plpython_to_hstore(PG_FUNCTION_ARGS)
177176
pairs[i].isnull= false;
178177
}
179178
}
180-
Py_DECREF(items_v);
179+
Py_DECREF(items);
181180

182181
pcount=hstoreUniquePairs(pairs,pcount,&buflen);
183182
out=hstorePairs(pairs,pcount,buflen);
184183
}
185184
PG_CATCH();
186185
{
187-
Py_DECREF(items_v);
186+
Py_DECREF(items);
188187
PG_RE_THROW();
189188
}
190189
PG_END_TRY();

‎contrib/jsonb_plpython/jsonb_plpython.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,14 @@ PLyMapping_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state)
237237
JsonbValue*out=NULL;
238238

239239
/* We need it volatile, since we use it after longjmp */
240-
volatilePyObject*items_v=NULL;
240+
PyObject*volatileitems=NULL;
241241

242242
pcount=PyMapping_Size(obj);
243-
items_v=PyMapping_Items(obj);
243+
items=PyMapping_Items(obj);
244244

245245
PG_TRY();
246246
{
247247
Py_ssize_ti;
248-
PyObject*items;
249-
250-
items= (PyObject*)items_v;
251248

252249
pushJsonbValue(jsonb_state,WJB_BEGIN_OBJECT,NULL);
253250

@@ -279,7 +276,7 @@ PLyMapping_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state)
279276
}
280277
PG_CATCH();
281278
{
282-
Py_DECREF(items_v);
279+
Py_DECREF(items);
283280
PG_RE_THROW();
284281
}
285282
PG_END_TRY();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp