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

Commitf73b2bb

Browse files
committed
Fix poorly thought-through code from commit5c3c3cd.
It's not entirely clear to me whether PyString_AsString can returnnull (looks like the answer might vary between Python 2 and 3).But in any case, this code's attempt to cope with the possibilitywas quite broken, because pstrdup() neither allows a null argumentnor ever returns a null.Moreover, the code below this point assumes that "message" is apalloc'd string, which would not be the case for a dgettext result.Fix both problems by doing the pstrdup step separately.
1 parent074050f commitf73b2bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎src/pl/plpython/plpy_plpymodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,12 @@ PLy_output(volatile int level, PyObject *self, PyObject *args, PyObject *kw)
424424
else
425425
so=PyObject_Str(args);
426426

427-
if (so==NULL|| ((message=pstrdup(PyString_AsString(so)))==NULL))
427+
if (so==NULL|| ((message=PyString_AsString(so))==NULL))
428428
{
429429
level=ERROR;
430430
message=dgettext(TEXTDOMAIN,"could not parse error message in plpy.elog");
431431
}
432+
message=pstrdup(message);
432433

433434
Py_XDECREF(so);
434435

@@ -444,7 +445,8 @@ PLy_output(volatile int level, PyObject *self, PyObject *args, PyObject *kw)
444445
if (PyTuple_Size(args)!=0)
445446
PLy_elog(ERROR,"the message is already specified");
446447

447-
pfree(message);
448+
if (message)
449+
pfree(message);
448450
message=object_to_string(value);
449451
}
450452
elseif (strcmp(keyword,"detail")==0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp