mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	* classobject.c: in instance_lenth, test result of call_object
for exception before using it. Fixed a few other places where the outcome of calling sq_length wasn't tested for exceptions (bltinmodule.c, ceval.c).
This commit is contained in:
		
							parent
							
								
									18fc5696c8
								
							
						
					
					
						commit
						d014ea6b5e
					
				
					 3 changed files with 6 additions and 0 deletions
				
			
		|  | @ -324,6 +324,8 @@ instance_length(inst) | ||||||
| 		return -1; | 		return -1; | ||||||
| 	res = call_object(func, (object *)NULL); | 	res = call_object(func, (object *)NULL); | ||||||
| 	DECREF(func); | 	DECREF(func); | ||||||
|  | 	if (res == NULL) | ||||||
|  | 		return -1; | ||||||
| 	if (is_intobject(res)) { | 	if (is_intobject(res)) { | ||||||
| 		outcome = getintvalue(res); | 		outcome = getintvalue(res); | ||||||
| 		if (outcome < 0) | 		if (outcome < 0) | ||||||
|  |  | ||||||
|  | @ -412,6 +412,8 @@ min_max(v, sign) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} | 	} | ||||||
| 	n = (*sq->sq_length)(v); | 	n = (*sq->sq_length)(v); | ||||||
|  | 	if (n < 0) | ||||||
|  | 		return NULL; | ||||||
| 	if (n == 0) { | 	if (n == 0) { | ||||||
| 		err_setstr(ValueError, "min() or max() of empty sequence"); | 		err_setstr(ValueError, "min() or max() of empty sequence"); | ||||||
| 		return NULL; | 		return NULL; | ||||||
|  |  | ||||||
|  | @ -1881,6 +1881,8 @@ loop_subscript(v, w) | ||||||
| 	} | 	} | ||||||
| 	i = getintvalue(w); | 	i = getintvalue(w); | ||||||
| 	n = (*sq->sq_length)(v); | 	n = (*sq->sq_length)(v); | ||||||
|  | 	if (n < 0) | ||||||
|  | 		return NULL; /* Exception */ | ||||||
| 	if (i >= n) | 	if (i >= n) | ||||||
| 		return NULL; /* End of loop */ | 		return NULL; /* End of loop */ | ||||||
| 	return (*sq->sq_item)(v, i); | 	return (*sq->sq_item)(v, i); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum