mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Issue #7743: Add checks for zero inputs to the lshift and mult functions;
this fixes the first bug described in issue #7743.
This commit is contained in:
		
							parent
							
								
									c64614e043
								
							
						
					
					
						commit
						fc5290458d
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
					@ -622,6 +622,15 @@ mult(Bigint *a, Bigint *b)
 | 
				
			||||||
    ULong z2;
 | 
					    ULong z2;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((!a->x[0] && a->wds == 1) || (!b->x[0] && b->wds == 1)) {
 | 
				
			||||||
 | 
					        c = Balloc(0);
 | 
				
			||||||
 | 
					        if (c == NULL)
 | 
				
			||||||
 | 
					            return NULL;
 | 
				
			||||||
 | 
					        c->wds = 1;
 | 
				
			||||||
 | 
					        c->x[0] = 0;
 | 
				
			||||||
 | 
					        return c;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (a->wds < b->wds) {
 | 
					    if (a->wds < b->wds) {
 | 
				
			||||||
        c = a;
 | 
					        c = a;
 | 
				
			||||||
        a = b;
 | 
					        a = b;
 | 
				
			||||||
| 
						 | 
					@ -820,6 +829,9 @@ lshift(Bigint *b, int k)
 | 
				
			||||||
    Bigint *b1;
 | 
					    Bigint *b1;
 | 
				
			||||||
    ULong *x, *x1, *xe, z;
 | 
					    ULong *x, *x1, *xe, z;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!k || (!b->x[0] && b->wds == 1))
 | 
				
			||||||
 | 
					        return b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    n = k >> 5;
 | 
					    n = k >> 5;
 | 
				
			||||||
    k1 = b->k;
 | 
					    k1 = b->k;
 | 
				
			||||||
    n1 = n + b->wds + 1;
 | 
					    n1 = n + b->wds + 1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue