File tree Expand file tree Collapse file tree 1 file changed +7
-71
lines changed Expand file tree Collapse file tree 1 file changed +7
-71
lines changed Original file line number Diff line number Diff line change @@ -1788,41 +1788,7 @@ pgquery_getresult(pgqueryobject * self, PyObject * args)
1788
1788
n = PQnfields (self -> last_result );
1789
1789
reslist = PyList_New (m );
1790
1790
1791
- if ((typ = malloc (sizeof (int ) * n )) == NULL )
1792
- {
1793
- PyErr_SetString (PyExc_SyntaxError , "memory error in getresult()." );
1794
- return NULL ;
1795
- }
1796
-
1797
- for (j = 0 ; j < n ; j ++ )
1798
- {
1799
- switch (PQftype (self -> last_result , j ))
1800
- {
1801
- case INT2OID :
1802
- case INT4OID :
1803
- case OIDOID :
1804
- typ [j ] = 1 ;
1805
- break ;
1806
-
1807
- case INT8OID :
1808
- typ [j ] = 2 ;
1809
- break ;
1810
-
1811
- case FLOAT4OID :
1812
- case FLOAT8OID :
1813
- case NUMERICOID :
1814
- typ [j ] = 3 ;
1815
- break ;
1816
-
1817
- case CASHOID :
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 );
1826
1792
1827
1793
for (i = 0 ; i < m ; i ++ )
1828
1794
{
@@ -1944,41 +1910,7 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
1944
1910
n = PQnfields (self -> last_result );
1945
1911
reslist = PyList_New (m );
1946
1912
1947
- if ((typ = malloc (sizeof (int ) * n )) == NULL )
1948
- {
1949
- PyErr_SetString (PyExc_SyntaxError , "memory error in dictresult()." );
1950
- return NULL ;
1951
- }
1952
-
1953
- for (j = 0 ; j < n ; j ++ )
1954
- {
1955
- switch (PQftype (self -> last_result , j ))
1956
- {
1957
- case INT2OID :
1958
- case INT4OID :
1959
- case OIDOID :
1960
- typ [j ] = 1 ;
1961
- break ;
1962
-
1963
- case INT8OID :
1964
- typ [j ] = 2 ;
1965
- break ;
1966
-
1967
- case FLOAT4OID :
1968
- case FLOAT8OID :
1969
- case NUMERICOID :
1970
- typ [j ] = 2 ;
1971
- break ;
1972
-
1973
- case CASHOID :
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 );
1982
1914
1983
1915
for (i = 0 ; i < m ; i ++ )
1984
1916
{
@@ -2034,9 +1966,13 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args)
2034
1966
* one */
2035
1967
s ++ ;
2036
1968
2037
- for (k = 0 ; * s ; s ++ )
1969
+ for (k = 0 ;
1970
+ * s && k < sizeof (cashbuf )/sizeof (cashbuf [0 ])- 1 ;
1971
+ s ++ )
1972
+ {
2038
1973
if (* s != ',' )
2039
1974
cashbuf [k ++ ] = * s ;
1975
+ }
2040
1976
2041
1977
cashbuf [k ] = 0 ;
2042
1978
val = PyFloat_FromDouble (strtod (cashbuf , NULL ) * mult );
You can’t perform that action at this time.
0 commit comments