Skip to content

Commit 3a621b1

Browse files
authored
Cast before multiplying (#9678)
1 parent 0257b35 commit 3a621b1

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/libImaging/Copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ _copy(Imaging imOut, Imaging imIn) {
3535

3636
ImagingSectionEnter(&cookie);
3737
if (imIn->block != NULL && imOut->block != NULL) {
38-
memcpy(imOut->block, imIn->block, imIn->ysize * imIn->linesize);
38+
memcpy(imOut->block, imIn->block, (size_t)imIn->ysize * imIn->linesize);
3939
} else {
4040
for (y = 0; y < imIn->ysize; y++) {
4141
memcpy(imOut->image[y], imIn->image[y], imIn->linesize);

src/libImaging/Draw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,8 @@ quarter_init(quarter_state *s, int32_t a, int32_t b) {
944944
s->cy = b % 2;
945945
s->ex = a % 2;
946946
s->ey = b;
947-
s->a2 = a * a;
948-
s->b2 = b * b;
947+
s->a2 = (int64_t)a * a;
948+
s->b2 = (int64_t)b * b;
949949
s->a2b2 = s->a2 * s->b2;
950950
s->finished = 0;
951951
}

src/libImaging/QuantOctree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ new_color_cube(int r, int g, int b, int a) {
8686
cube->aOffset = 0;
8787

8888
/* the number of color buckets */
89-
cube->size = cube->rWidth * cube->gWidth * cube->bWidth * cube->aWidth;
89+
cube->size = (unsigned long)cube->rWidth * cube->gWidth *
90+
(unsigned long)cube->bWidth * cube->aWidth;
9091
/* malloc check ok, overflow checked above */
9192
cube->buckets = calloc(cube->size, sizeof(struct _ColorBucket));
9293

0 commit comments

Comments
 (0)