mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	Need a (size_t) cast instead of (unsigned) to be big enough for a Py_ssize_t.
This commit is contained in:
		
							parent
							
								
									e4969f5df8
								
							
						
					
					
						commit
						c20830804d
					
				
					 1 changed files with 12 additions and 6 deletions
				
			
		| 
						 | 
					@ -1,6 +1,12 @@
 | 
				
			||||||
#include "Python.h"
 | 
					#include "Python.h"
 | 
				
			||||||
#include "structmember.h"
 | 
					#include "structmember.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef STDC_HEADERS
 | 
				
			||||||
 | 
					#include <stddef.h>
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#include <sys/types.h>          /* For size_t */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* collections module implementation of a deque() datatype
 | 
					/* collections module implementation of a deque() datatype
 | 
				
			||||||
   Written and maintained by Raymond D. Hettinger <python@rcn.com>
 | 
					   Written and maintained by Raymond D. Hettinger <python@rcn.com>
 | 
				
			||||||
   Copyright (c) 2004-2015 Python Software Foundation.
 | 
					   Copyright (c) 2004-2015 Python Software Foundation.
 | 
				
			||||||
| 
						 | 
					@ -780,15 +786,15 @@ deque_item(dequeobject *deque, Py_ssize_t i)
 | 
				
			||||||
        b = deque->rightblock;
 | 
					        b = deque->rightblock;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        i += deque->leftindex;
 | 
					        i += deque->leftindex;
 | 
				
			||||||
        n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
 | 
					        n = (Py_ssize_t)((size_t) i / BLOCKLEN);
 | 
				
			||||||
        i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
 | 
					        i = (Py_ssize_t)((size_t) i % BLOCKLEN);
 | 
				
			||||||
        if (index < (Py_SIZE(deque) >> 1)) {
 | 
					        if (index < (Py_SIZE(deque) >> 1)) {
 | 
				
			||||||
            b = deque->leftblock;
 | 
					            b = deque->leftblock;
 | 
				
			||||||
            while (n--)
 | 
					            while (n--)
 | 
				
			||||||
                b = b->rightlink;
 | 
					                b = b->rightlink;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            n = (Py_ssize_t)(
 | 
					            n = (Py_ssize_t)(
 | 
				
			||||||
                    ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
 | 
					                    ((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
 | 
				
			||||||
                    / BLOCKLEN - n);
 | 
					                    / BLOCKLEN - n);
 | 
				
			||||||
            b = deque->rightblock;
 | 
					            b = deque->rightblock;
 | 
				
			||||||
            while (n--)
 | 
					            while (n--)
 | 
				
			||||||
| 
						 | 
					@ -839,15 +845,15 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
 | 
				
			||||||
        return deque_del_item(deque, i);
 | 
					        return deque_del_item(deque, i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    i += deque->leftindex;
 | 
					    i += deque->leftindex;
 | 
				
			||||||
    n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
 | 
					    n = (Py_ssize_t)((size_t) i / BLOCKLEN);
 | 
				
			||||||
    i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
 | 
					    i = (Py_ssize_t)((size_t) i % BLOCKLEN);
 | 
				
			||||||
    if (index <= halflen) {
 | 
					    if (index <= halflen) {
 | 
				
			||||||
        b = deque->leftblock;
 | 
					        b = deque->leftblock;
 | 
				
			||||||
        while (n--)
 | 
					        while (n--)
 | 
				
			||||||
            b = b->rightlink;
 | 
					            b = b->rightlink;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        n = (Py_ssize_t)(
 | 
					        n = (Py_ssize_t)(
 | 
				
			||||||
                ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
 | 
					                ((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
 | 
				
			||||||
                / BLOCKLEN - n);
 | 
					                / BLOCKLEN - n);
 | 
				
			||||||
        b = deque->rightblock;
 | 
					        b = deque->rightblock;
 | 
				
			||||||
        while (n--)
 | 
					        while (n--)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue