mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	Issue #1621: Avoid signed int negation overflow in audioop
This commit is contained in:
		
							parent
							
								
									e3d747496e
								
							
						
					
					
						commit
						6fb90905e2
					
				
					 2 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -26,6 +26,8 @@ Core and Builtins
 | 
			
		|||
Library
 | 
			
		||||
-------
 | 
			
		||||
 | 
			
		||||
- Issue #1621: Avoid signed int negation overflow in the "audioop" module.
 | 
			
		||||
 | 
			
		||||
- Issue #27533: Release GIL in nt._isdir
 | 
			
		||||
 | 
			
		||||
- Issue #17711: Fixed unpickling by the persistent ID with protocol 0.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -446,7 +446,9 @@ audioop_max_impl(PyObject *module, Py_buffer *fragment, int width)
 | 
			
		|||
        return NULL;
 | 
			
		||||
    for (i = 0; i < fragment->len; i += width) {
 | 
			
		||||
        int val = GETRAWSAMPLE(width, fragment->buf, i);
 | 
			
		||||
        if (val < 0) absval = (-val);
 | 
			
		||||
        /* Cast to unsigned before negating. Unsigned overflow is well-
 | 
			
		||||
        defined, but signed overflow is not. */
 | 
			
		||||
        if (val < 0) absval = -(unsigned int)val;
 | 
			
		||||
        else absval = val;
 | 
			
		||||
        if (absval > max) max = absval;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue