@@ -415,7 +415,8 @@ diophantine_dfs(unsigned int n,
415
415
x [0 ] = x1 + c1 * t_l ;
416
416
x [1 ] = x2 - c2 * t_l ;
417
417
if (require_ub_nontrivial ) {
418
- int j , is_ub_trivial ;
418
+ unsigned int j ;
419
+ int is_ub_trivial ;
419
420
420
421
is_ub_trivial = 1 ;
421
422
for (j = 0 ; j < n ; ++ j ) {
@@ -711,7 +712,7 @@ static int
711
712
strides_to_terms (PyArrayObject * arr , diophantine_term_t * terms ,
712
713
unsigned int * nterms , int skip_empty )
713
714
{
714
- unsigned int i ;
715
+ int i ;
715
716
716
717
for (i = 0 ; i < PyArray_NDIM (arr ); ++ i ) {
717
718
if (skip_empty ) {
@@ -756,9 +757,11 @@ solve_may_share_memory(PyArrayObject *a, PyArrayObject *b,
756
757
Py_ssize_t max_work )
757
758
{
758
759
npy_int64 rhs ;
759
- diophantine_term_t terms [2 * NPY_MAXDIMS + 2 ];
760
- npy_uintp start1 = 0 , start2 = 0 , end1 = 0 , end2 = 0 , size1 = 0 , size2 = 0 ;
761
- npy_int64 x [2 * NPY_MAXDIMS + 2 ];
760
+ diophantine_term_t terms [2 * NPY_MAXDIMS + 2 ];
761
+ npy_uintp start1 = 0 , end1 = 0 , size1 = 0 ;
762
+ npy_uintp start2 = 0 , end2 = 0 , size2 = 0 ;
763
+ npy_uintp uintp_rhs ;
764
+ npy_int64 x [2 * NPY_MAXDIMS + 2 ];
762
765
unsigned int nterms ;
763
766
764
767
get_array_memory_extents (a , & start1 , & end1 , & size1 );
@@ -797,12 +800,12 @@ solve_may_share_memory(PyArrayObject *a, PyArrayObject *b,
797
800
the extent check above.)
798
801
*/
799
802
800
- rhs = MIN (end2 - 1 - start1 , end1 - 1 - start2 );
801
-
802
- if (rhs != (npy_uintp )rhs ) {
803
+ uintp_rhs = MIN (end2 - 1 - start1 , end1 - 1 - start2 );
804
+ if (uintp_rhs > NPY_MAX_INT64 ) {
803
805
/* Integer overflow */
804
806
return MEM_OVERLAP_OVERFLOW ;
805
807
}
808
+ rhs = (npy_int64 )uintp_rhs ;
806
809
807
810
nterms = 0 ;
808
811
if (strides_to_terms (a , terms , & nterms , 1 )) {
@@ -845,8 +848,7 @@ solve_may_have_internal_overlap(PyArrayObject *a, Py_ssize_t max_work)
845
848
{
846
849
diophantine_term_t terms [NPY_MAXDIMS + 1 ];
847
850
npy_int64 x [NPY_MAXDIMS + 1 ];
848
- unsigned int nterms ;
849
- int i , j ;
851
+ unsigned int i , j , nterms ;
850
852
851
853
if (PyArray_ISCONTIGUOUS (a )) {
852
854
/* Quick case */
0 commit comments