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

Commitf5fea08

Browse files
committed
This is a quick patch to fix a crash in pgquery_dictresult() introduced
recently. I just ran into it while running a set of python test scripts,and I'm not sure who the normal maintainer is for interfaces/python.John Nield
1 parentb60acaf commitf5fea08

File tree

1 file changed

+7
-71
lines changed

1 file changed

+7
-71
lines changed

‎src/interfaces/python/pgmodule.c

Lines changed: 7 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,41 +1788,7 @@ pgquery_getresult(pgqueryobject * self, PyObject * args)
17881788
n=PQnfields(self->last_result);
17891789
reslist=PyList_New(m);
17901790

1791-
if ((typ=malloc(sizeof(int)*n))==NULL)
1792-
{
1793-
PyErr_SetString(PyExc_SyntaxError,"memory error in getresult().");
1794-
returnNULL;
1795-
}
1796-
1797-
for (j=0;j<n;j++)
1798-
{
1799-
switch (PQftype(self->last_result,j))
1800-
{
1801-
caseINT2OID:
1802-
caseINT4OID:
1803-
caseOIDOID:
1804-
typ[j]=1;
1805-
break;
1806-
1807-
caseINT8OID:
1808-
typ[j]=2;
1809-
break;
1810-
1811-
caseFLOAT4OID:
1812-
caseFLOAT8OID:
1813-
caseNUMERICOID:
1814-
typ[j]=3;
1815-
break;
1816-
1817-
caseCASHOID:
1818-
typ[j]=4;
1819-
break;
1820-
1821-
default:
1822-
typ[j]=5;
1823-
break;
1824-
}
1825-
}
1791+
typ=get_type_array(self->last_result,n);
18261792

18271793
for (i=0;i<m;i++)
18281794
{
@@ -1944,41 +1910,7 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
19441910
n=PQnfields(self->last_result);
19451911
reslist=PyList_New(m);
19461912

1947-
if ((typ=malloc(sizeof(int)*n))==NULL)
1948-
{
1949-
PyErr_SetString(PyExc_SyntaxError,"memory error in dictresult().");
1950-
returnNULL;
1951-
}
1952-
1953-
for (j=0;j<n;j++)
1954-
{
1955-
switch (PQftype(self->last_result,j))
1956-
{
1957-
caseINT2OID:
1958-
caseINT4OID:
1959-
caseOIDOID:
1960-
typ[j]=1;
1961-
break;
1962-
1963-
caseINT8OID:
1964-
typ[j]=2;
1965-
break;
1966-
1967-
caseFLOAT4OID:
1968-
caseFLOAT8OID:
1969-
caseNUMERICOID:
1970-
typ[j]=2;
1971-
break;
1972-
1973-
caseCASHOID:
1974-
typ[j]=3;
1975-
break;
1976-
1977-
default:
1978-
typ[j]=4;
1979-
break;
1980-
}
1981-
}
1913+
typ=get_type_array(self->last_result,n);
19821914

19831915
for (i=0;i<m;i++)
19841916
{
@@ -2034,9 +1966,13 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
20341966
* one */
20351967
s++;
20361968

2037-
for (k=0;*s;s++)
1969+
for (k=0;
1970+
*s&&k<sizeof(cashbuf)/sizeof(cashbuf[0])-1;
1971+
s++)
1972+
{
20381973
if (*s!=',')
20391974
cashbuf[k++]=*s;
1975+
}
20401976

20411977
cashbuf[k]=0;
20421978
val=PyFloat_FromDouble(strtod(cashbuf,NULL)*mult);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp