mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	Coverity issue CID #182
size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
This commit is contained in:
		
							parent
							
								
									7b1e119f8c
								
							
						
					
					
						commit
						87dcf3d260
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -369,7 +369,17 @@ element_resize(ElementObject* self, int extra)
 | 
			
		|||
    if (size > self->extra->allocated) {
 | 
			
		||||
        /* use Python 2.4's list growth strategy */
 | 
			
		||||
        size = (size >> 3) + (size < 9 ? 3 : 6) + size;
 | 
			
		||||
        /* Coverity CID #182 size_error: Allocating 1 bytes to pointer "children"
 | 
			
		||||
         * which needs at least 4 bytes. 
 | 
			
		||||
         * Although it's a false alarm always assume at least one child to 
 | 
			
		||||
         * be safe.
 | 
			
		||||
         */
 | 
			
		||||
        size = size ? size : 1;
 | 
			
		||||
        if (self->extra->children != self->extra->_children) {
 | 
			
		||||
            /* Coverity CID #182 size_error: Allocating 1 bytes to pointer
 | 
			
		||||
             * "children", which needs at least 4 bytes. Although it's a 
 | 
			
		||||
             * false alarm always assume at least one child to be safe.
 | 
			
		||||
             */
 | 
			
		||||
            children = PyObject_Realloc(self->extra->children,
 | 
			
		||||
                                        size * sizeof(PyObject*));
 | 
			
		||||
            if (!children)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue