mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Merge pull request #5122 from radarhere/warnings
This commit is contained in:
		
						commit
						ce3d80e713
					
				| 
						 | 
					@ -3928,7 +3928,7 @@ _set_blocks_max(PyObject* self, PyObject* args)
 | 
				
			||||||
            "blocks_max should be greater than 0");
 | 
					            "blocks_max should be greater than 0");
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if ( blocks_max > SIZE_MAX/sizeof(ImagingDefaultArena.blocks_pool[0])) {
 | 
					    else if ( (unsigned long)blocks_max > SIZE_MAX/sizeof(ImagingDefaultArena.blocks_pool[0])) {
 | 
				
			||||||
        PyErr_SetString(PyExc_ValueError,
 | 
					        PyErr_SetString(PyExc_ValueError,
 | 
				
			||||||
            "blocks_max is too large");
 | 
					            "blocks_max is too large");
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1115,7 +1115,7 @@ int clip_tree_do_clip(clip_node* root, int32_t x0, int32_t y, int32_t x1, event_
 | 
				
			||||||
      if ((root->type == CT_OR && (
 | 
					      if ((root->type == CT_OR && (
 | 
				
			||||||
              (t->type == 1 && (tail == NULL || tail->type == -1)) ||
 | 
					              (t->type == 1 && (tail == NULL || tail->type == -1)) ||
 | 
				
			||||||
              (t->type == -1 && k1 == 0 && k2 == 0)
 | 
					              (t->type == -1 && k1 == 0 && k2 == 0)
 | 
				
			||||||
          )) || 
 | 
					          )) ||
 | 
				
			||||||
          (root->type == CT_AND && (
 | 
					          (root->type == CT_AND && (
 | 
				
			||||||
              (t->type == 1 && (tail == NULL || tail->type == -1) && k1 > 0 && k2 > 0) ||
 | 
					              (t->type == 1 && (tail == NULL || tail->type == -1) && k1 > 0 && k2 > 0) ||
 | 
				
			||||||
              (t->type == -1 && tail != NULL && tail->type == 1 && (k1 == 0 || k2 == 0))
 | 
					              (t->type == -1 && tail != NULL && tail->type == 1 && (k1 == 0 || k2 == 0))
 | 
				
			||||||
| 
						 | 
					@ -1359,7 +1359,7 @@ void pie_init(clip_ellipse_state* s, int32_t a, int32_t b, int32_t w, float al,
 | 
				
			||||||
  rc->a = yr;
 | 
					  rc->a = yr;
 | 
				
			||||||
  rc->b = -xr;
 | 
					  rc->b = -xr;
 | 
				
			||||||
  rc->c = 0;
 | 
					  rc->c = 0;
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
  s->root = s->nodes + s->node_count++;
 | 
					  s->root = s->nodes + s->node_count++;
 | 
				
			||||||
  s->root->l = lc;
 | 
					  s->root->l = lc;
 | 
				
			||||||
  s->root->r = rc;
 | 
					  s->root->r = rc;
 | 
				
			||||||
| 
						 | 
					@ -1630,7 +1630,7 @@ allocate(ImagingOutline outline, int extra)
 | 
				
			||||||
            /* malloc check ok, uses calloc for overflow */
 | 
					            /* malloc check ok, uses calloc for overflow */
 | 
				
			||||||
            e = calloc(outline->size, sizeof(Edge));
 | 
					            e = calloc(outline->size, sizeof(Edge));
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            if (outline->size > INT_MAX / sizeof(Edge)) {
 | 
					            if (outline->size > INT_MAX / (int)sizeof(Edge)) {
 | 
				
			||||||
                return NULL;
 | 
					                return NULL;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            /* malloc check ok, overflow checked above */
 | 
					            /* malloc check ok, overflow checked above */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -742,10 +742,12 @@ j2k_decode_entry(Imaging im, ImagingCodecState state)
 | 
				
			||||||
           swapped), bail. */
 | 
					           swapped), bail. */
 | 
				
			||||||
        if (tile_info.x0 >= tile_info.x1
 | 
					        if (tile_info.x0 >= tile_info.x1
 | 
				
			||||||
            || tile_info.y0 >= tile_info.y1
 | 
					            || tile_info.y0 >= tile_info.y1
 | 
				
			||||||
            || tile_info.x0 < (OPJ_INT32)image->x0
 | 
					            || tile_info.x0 < 0
 | 
				
			||||||
            || tile_info.y0 < (OPJ_INT32)image->y0
 | 
					            || tile_info.y0 < 0
 | 
				
			||||||
            || tile_info.x1 - image->x0 > im->xsize
 | 
					            || (OPJ_UINT32)tile_info.x0 < image->x0
 | 
				
			||||||
            || tile_info.y1 - image->y0 > im->ysize) {
 | 
					            || (OPJ_UINT32)tile_info.y0 < image->y0
 | 
				
			||||||
 | 
					            || (OPJ_INT32)(tile_info.x1 - image->x0) > im->xsize
 | 
				
			||||||
 | 
					            || (OPJ_INT32)(tile_info.y1 - image->y0) > im->ysize) {
 | 
				
			||||||
            state->errcode = IMAGING_CODEC_BROKEN;
 | 
					            state->errcode = IMAGING_CODEC_BROKEN;
 | 
				
			||||||
            state->state = J2K_STATE_FAILED;
 | 
					            state->state = J2K_STATE_FAILED;
 | 
				
			||||||
            goto quick_exit;
 | 
					            goto quick_exit;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,7 @@ ImagingRankFilter(Imaging im, int size, int rank)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* malloc check ok, for overflow in the define below */
 | 
					    /* malloc check ok, for overflow in the define below */
 | 
				
			||||||
    if (size > INT_MAX / size ||
 | 
					    if (size > INT_MAX / size ||
 | 
				
			||||||
        size > INT_MAX / (size * sizeof(FLOAT32))) {
 | 
					        size > INT_MAX / (size * (int)sizeof(FLOAT32))) {
 | 
				
			||||||
        return (Imaging) ImagingError_ValueError("filter size too large");
 | 
					        return (Imaging) ImagingError_ValueError("filter size too large");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -208,7 +208,7 @@ precompute_coeffs(int inSize, float in0, float in1, int outSize,
 | 
				
			||||||
    ksize = (int) ceil(support) * 2 + 1;
 | 
					    ksize = (int) ceil(support) * 2 + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // check for overflow
 | 
					    // check for overflow
 | 
				
			||||||
    if (outSize > INT_MAX / (ksize * sizeof(double))) {
 | 
					    if (outSize > INT_MAX / (ksize * (int)sizeof(double))) {
 | 
				
			||||||
        ImagingError_MemoryError();
 | 
					        ImagingError_MemoryError();
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user