mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Include mymath.h instead of declaring prototypes for math functions.
Fix leak and unchecked error in complex().
This commit is contained in:
		
							parent
							
								
									1d60614d42
								
							
						
					
					
						commit
						fe4b6ee775
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		|  | @ -33,6 +33,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||||
| #include "compile.h" | #include "compile.h" | ||||||
| #include "eval.h" | #include "eval.h" | ||||||
| 
 | 
 | ||||||
|  | #include "mymath.h" | ||||||
|  | 
 | ||||||
| /* Forward */ | /* Forward */ | ||||||
| static object *filterstring PROTO((object *, object *)); | static object *filterstring PROTO((object *, object *)); | ||||||
| static object *filtertuple  PROTO((object *, object *)); | static object *filtertuple  PROTO((object *, object *)); | ||||||
|  | @ -284,7 +286,7 @@ builtin_complex(self, args) | ||||||
| 	object *self; | 	object *self; | ||||||
| 	object *args; | 	object *args; | ||||||
| { | { | ||||||
| 	object *r, *i; | 	object *r, *i, *tmp; | ||||||
| 	number_methods *nbr, *nbi; | 	number_methods *nbr, *nbi; | ||||||
| 	Py_complex cr, ci; | 	Py_complex cr, ci; | ||||||
| 
 | 
 | ||||||
|  | @ -302,7 +304,11 @@ builtin_complex(self, args) | ||||||
| 	if (is_complexobject(r)) | 	if (is_complexobject(r)) | ||||||
| 		cr = ((complexobject*)r)->cval; | 		cr = ((complexobject*)r)->cval; | ||||||
| 	else { | 	else { | ||||||
| 		cr.real = getfloatvalue((*nbr->nb_float)(r)); | 		tmp = (*nbr->nb_float)(r); | ||||||
|  | 		if (tmp == NULL) | ||||||
|  | 			return NULL; | ||||||
|  | 		cr.real = getfloatvalue(tmp); | ||||||
|  | 		DECREF(tmp); | ||||||
| 		cr.imag = 0.; | 		cr.imag = 0.; | ||||||
| 	} | 	} | ||||||
| 	if (i == NULL) { | 	if (i == NULL) { | ||||||
|  | @ -312,7 +318,11 @@ builtin_complex(self, args) | ||||||
| 	else if (is_complexobject(i)) | 	else if (is_complexobject(i)) | ||||||
| 		ci = ((complexobject*)i)->cval; | 		ci = ((complexobject*)i)->cval; | ||||||
| 	else { | 	else { | ||||||
| 		ci.real = getfloatvalue((*nbi->nb_float)(i)); | 		tmp = (*nbr->nb_float)(r); | ||||||
|  | 		if (tmp == NULL) | ||||||
|  | 			return NULL; | ||||||
|  | 		ci.real = getfloatvalue(tmp); | ||||||
|  | 		DECREF(tmp); | ||||||
| 		ci.imag = 0.; | 		ci.imag = 0.; | ||||||
| 	} | 	} | ||||||
| 	cr.real -= ci.imag; | 	cr.real -= ci.imag; | ||||||
|  | @ -1354,8 +1364,6 @@ builtin_round(self, args) | ||||||
| 	object *self; | 	object *self; | ||||||
| 	object *args; | 	object *args; | ||||||
| { | { | ||||||
| 	extern double floor PROTO((double)); |  | ||||||
| 	extern double ceil PROTO((double)); |  | ||||||
| 	double x; | 	double x; | ||||||
| 	double f; | 	double f; | ||||||
| 	int ndigits = 0; | 	int ndigits = 0; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum