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)
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- 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 );
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- 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 );
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 );
You can’t perform that action at this time.
0 commit comments