Skip to content

Commit ca4b4c6

Browse files
author
Cristy
committed
add additional checks for casting double to size_t
1 parent 39f6601 commit ca4b4c6

23 files changed

+161
-150
lines changed

coders/histogram.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
304304
break;
305305
if ((channel & RedChannel) != 0)
306306
{
307-
y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
307+
y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
308308
histogram[x].red-0.5));
309309
r=q+y;
310310
for ( ; y < (ssize_t) histogram_image->rows; y++)
@@ -315,7 +315,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
315315
}
316316
if ((channel & GreenChannel) != 0)
317317
{
318-
y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
318+
y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
319319
histogram[x].green-0.5));
320320
r=q+y;
321321
for ( ; y < (ssize_t) histogram_image->rows; y++)
@@ -326,7 +326,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
326326
}
327327
if ((channel & BlueChannel) != 0)
328328
{
329-
y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
329+
y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
330330
histogram[x].blue-0.5));
331331
r=q+y;
332332
for ( ; y < (ssize_t) histogram_image->rows; y++)

coders/jpeg.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,8 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info,
24442444
if (image->debug != MagickFalse)
24452445
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
24462446
"Image resolution: %.20g,%.20g",image->x_resolution,image->y_resolution);
2447-
if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
2447+
if ((image->x_resolution >= 0) && (image->x_resolution < (double) SHRT_MAX) &&
2448+
(image->y_resolution >= 0) && (image->y_resolution < (double) SHRT_MAX))
24482449
{
24492450
/*
24502451
Set image resolution.

coders/pcl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
295295
/*
296296
Set PCL render geometry.
297297
*/
298-
width=(size_t) CastDoubleToLong(floor(bounds.x2-bounds.x1+0.5));
299-
height=(size_t) CastDoubleToLong(floor(bounds.y2-bounds.y1+0.5));
298+
width=(size_t) CastDoubleToSSizeT(floor(bounds.x2-bounds.x1+0.5));
299+
height=(size_t) CastDoubleToSSizeT(floor(bounds.y2-bounds.y1+0.5));
300300
if (width > page.width)
301301
page.width=width;
302302
if (height > page.height)

coders/png.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
% November 1997 %
1919
% %
2020
% %
21-
% Copyright 1999 ImageMagick Studio LLC, a non-profit organization %
21+
% Copyright 1999 ImageMagick Studio LLC, a non-profit organization %
2222
% dedicated to making software imaging solutions freely available. %
2323
% %
2424
% You may not use this file except in compliance with the License. You may %
@@ -9924,17 +9924,19 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
99249924
if (image->units == PixelsPerInchResolution)
99259925
{
99269926
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
9927-
ping_pHYs_x_resolution=
9928-
(png_uint_32) ((100.0*image->x_resolution+0.5)/2.54);
9929-
ping_pHYs_y_resolution=
9930-
(png_uint_32) ((100.0*image->y_resolution+0.5)/2.54);
9927+
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT((100.0*
9928+
image->x_resolution)/2.54);
9929+
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT((100.0*
9930+
image->y_resolution+0.5)/2.54);
99319931
}
99329932

99339933
else if (image->units == PixelsPerCentimeterResolution)
99349934
{
99359935
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
9936-
ping_pHYs_x_resolution=(png_uint_32) (100.0*image->x_resolution+0.5);
9937-
ping_pHYs_y_resolution=(png_uint_32) (100.0*image->y_resolution+0.5);
9936+
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT(100.0*
9937+
image->x_resolution);
9938+
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT(100.0*
9939+
image->y_resolution);
99389940
}
99399941

99409942
else

coders/tiff.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1406,9 +1406,9 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
14061406
if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) &&
14071407
(TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1))
14081408
{
1409-
image->page.x=CastDoubleToLong(ceil(x_position*
1409+
image->page.x=CastDoubleToSSizeT(ceil(x_position*
14101410
image->x_resolution-0.5));
1411-
image->page.y=CastDoubleToLong(ceil(y_position*
1411+
image->page.y=CastDoubleToSSizeT(ceil(y_position*
14121412
image->y_resolution-0.5));
14131413
}
14141414
if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1)

coders/txt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static Image *ReadTEXTImage(const ImageInfo *image_info,
278278
draw_info=DestroyDrawInfo(draw_info);
279279
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
280280
}
281-
page.y=CastDoubleToLong(ceil((double) page.y+metrics.ascent-0.5));
281+
page.y=CastDoubleToSSizeT(ceil((double) page.y+metrics.ascent-0.5));
282282
(void) FormatLocaleString(geometry,MaxTextExtent,"%gx%g%+g%+g",(double)
283283
image->columns,(double) image->rows,(double) page.x,(double) page.y);
284284
(void) CloneString(&draw_info->geometry,geometry);
@@ -576,7 +576,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
576576
index),range);
577577
pixel.opacity=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
578578
opacity),range);
579-
q=GetAuthenticPixels(image,CastDoubleToLong(x_offset),CastDoubleToLong(
579+
q=GetAuthenticPixels(image,CastDoubleToSSizeT(x_offset),CastDoubleToSSizeT(
580580
y_offset),1,1,exception);
581581
if (q == (PixelPacket *) NULL)
582582
{

magick/annotate.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1842,8 +1842,8 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
18421842

18431843
if (status == MagickFalse)
18441844
continue;
1845-
x_offset=CastDoubleToLong(ceil(point.x-0.5));
1846-
y_offset=CastDoubleToLong(ceil(point.y+y-0.5));
1845+
x_offset=CastDoubleToSSizeT(ceil(point.x-0.5));
1846+
y_offset=CastDoubleToSSizeT(ceil(point.y+y-0.5));
18471847
if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
18481848
continue;
18491849
q=(PixelPacket *) NULL;
@@ -1858,7 +1858,7 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
18581858
n=y*bitmap->bitmap.pitch;
18591859
for (x=0; x < (ssize_t) bitmap->bitmap.width; x++, n++)
18601860
{
1861-
x_offset=CastDoubleToLong(ceil(point.x+x-0.5));
1861+
x_offset=CastDoubleToSSizeT(ceil(point.x+x-0.5));
18621862
if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
18631863
{
18641864
if (q != (PixelPacket *) NULL)
@@ -2209,7 +2209,7 @@ static MagickBooleanType RenderPostscript(Image *image,
22092209
crop_info=GetImageBoundingBox(annotate_image,&annotate_image->exception);
22102210
crop_info.height=(size_t) ((resolution.y/DefaultResolution)*
22112211
ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5);
2212-
crop_info.y=CastDoubleToLong(ceil((resolution.y/DefaultResolution)*
2212+
crop_info.y=CastDoubleToSSizeT(ceil((resolution.y/DefaultResolution)*
22132213
extent.y/8.0-0.5));
22142214
(void) FormatLocaleString(geometry,MaxTextExtent,
22152215
"%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)

magick/constitute.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
864864
else
865865
next->delay=(size_t) floor(geometry_info.rho+0.5);
866866
if ((flags & SigmaValue) != 0)
867-
next->ticks_per_second=CastDoubleToLong(floor(
867+
next->ticks_per_second=CastDoubleToSSizeT(floor(
868868
geometry_info.sigma+0.5));
869869
}
870870
option=GetImageOption(image_info,"dispose");

magick/draw.c

+33-33
Original file line numberDiff line numberDiff line change
@@ -1252,8 +1252,8 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
12521252
edge.y2=image->rows-1.0;
12531253
GetMagickPixelPacket(image,&zero);
12541254
exception=(&image->exception);
1255-
start=CastDoubleToLong(ceil(edge.y1-0.5));
1256-
stop=CastDoubleToLong(floor(edge.y2+0.5));
1255+
start=CastDoubleToSSizeT(ceil(edge.y1-0.5));
1256+
stop=CastDoubleToSSizeT(floor(edge.y2+0.5));
12571257
source_view=AcquireVirtualCacheView(source,exception);
12581258
image_view=AcquireAuthenticCacheView(image,exception);
12591259
#if defined(MAGICKCORE_OPENMP_SUPPORT)
@@ -1291,17 +1291,17 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
12911291
inverse_edge.x1=0.0;
12921292
if (inverse_edge.x2 > image->columns-1.0)
12931293
inverse_edge.x2=image->columns-1.0;
1294-
q=GetCacheViewAuthenticPixels(image_view,CastDoubleToLong(
1295-
ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToLong(floor(
1294+
q=GetCacheViewAuthenticPixels(image_view,CastDoubleToSSizeT(
1295+
ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToSSizeT(floor(
12961296
inverse_edge.x2+0.5)-ceil(inverse_edge.x1-0.5)+1),1,exception);
12971297
if (q == (PixelPacket *) NULL)
12981298
continue;
12991299
indexes=GetCacheViewAuthenticIndexQueue(image_view);
13001300
pixel=zero;
13011301
composite=zero;
13021302
x_offset=0;
1303-
for (x=CastDoubleToLong(ceil(inverse_edge.x1-0.5));
1304-
x <= CastDoubleToLong(floor(inverse_edge.x2+0.5)); x++)
1303+
for (x=CastDoubleToSSizeT(ceil(inverse_edge.x1-0.5));
1304+
x <= CastDoubleToSSizeT(floor(inverse_edge.x2+0.5)); x++)
13051305
{
13061306
point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
13071307
inverse_affine.tx;
@@ -2075,8 +2075,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
20752075
case UndefinedSpread:
20762076
case PadSpread:
20772077
{
2078-
if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
2079-
(y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
2078+
if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
2079+
(y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
20802080
{
20812081
offset=GetStopColorOffset(gradient,x,y);
20822082
if (gradient->type != RadialGradient)
@@ -2103,8 +2103,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
21032103
}
21042104
case ReflectSpread:
21052105
{
2106-
if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
2107-
(y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
2106+
if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
2107+
(y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
21082108
{
21092109
offset=GetStopColorOffset(gradient,x,y);
21102110
if (gradient->type != RadialGradient)
@@ -2145,8 +2145,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
21452145

21462146
antialias=MagickFalse;
21472147
repeat=0.0;
2148-
if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
2149-
(y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
2148+
if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
2149+
(y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
21502150
{
21512151
offset=GetStopColorOffset(gradient,x,y);
21522152
if (gradient->type == LinearGradient)
@@ -3472,14 +3472,14 @@ static MagickBooleanType RenderMVGContent(Image *image,
34723472
(void) GetNextToken(q,&q,extent,token);
34733473
(void) CopyMagickString(name,token,MaxTextExtent);
34743474
(void) GetNextToken(q,&q,extent,token);
3475-
bounds.x=CastDoubleToLong(ceil(GetDrawValue(token,
3475+
bounds.x=CastDoubleToSSizeT(ceil(GetDrawValue(token,
34763476
&next_token)-0.5));
34773477
if (token == next_token)
34783478
ThrowPointExpectedException(image,token);
34793479
(void) GetNextToken(q,&q,extent,token);
34803480
if (*token == ',')
34813481
(void) GetNextToken(q,&q,extent,token);
3482-
bounds.y=CastDoubleToLong(ceil(GetDrawValue(token,
3482+
bounds.y=CastDoubleToSSizeT(ceil(GetDrawValue(token,
34833483
&next_token)-0.5));
34843484
if (token == next_token)
34853485
ThrowPointExpectedException(image,token);
@@ -3895,14 +3895,14 @@ static MagickBooleanType RenderMVGContent(Image *image,
38953895
if (LocaleCompare("viewbox",keyword) == 0)
38963896
{
38973897
(void) GetNextToken(q,&q,extent,token);
3898-
graphic_context[n]->viewbox.x=CastDoubleToLong(ceil(
3898+
graphic_context[n]->viewbox.x=CastDoubleToSSizeT(ceil(
38993899
GetDrawValue(token,&next_token)-0.5));
39003900
if (token == next_token)
39013901
ThrowPointExpectedException(image,token);
39023902
(void) GetNextToken(q,&q,extent,token);
39033903
if (*token == ',')
39043904
(void) GetNextToken(q,&q,extent,token);
3905-
graphic_context[n]->viewbox.y=CastDoubleToLong(ceil(
3905+
graphic_context[n]->viewbox.y=CastDoubleToSSizeT(ceil(
39063906
GetDrawValue(token,&next_token)-0.5));
39073907
if (token == next_token)
39083908
ThrowPointExpectedException(image,token);
@@ -4974,10 +4974,10 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
49744974
(double) image->columns-1.0 : bounds.x2;
49754975
bounds.y2=bounds.y2 < 0.0 ? 0.0 : bounds.y2 >= (double) image->rows-1.0 ?
49764976
(double) image->rows-1.0 : bounds.y2;
4977-
poly_extent.x1=CastDoubleToLong(ceil(bounds.x1-0.5));
4978-
poly_extent.y1=CastDoubleToLong(ceil(bounds.y1-0.5));
4979-
poly_extent.x2=CastDoubleToLong(floor(bounds.x2+0.5));
4980-
poly_extent.y2=CastDoubleToLong(floor(bounds.y2+0.5));
4977+
poly_extent.x1=CastDoubleToSSizeT(ceil(bounds.x1-0.5));
4978+
poly_extent.y1=CastDoubleToSSizeT(ceil(bounds.y1-0.5));
4979+
poly_extent.x2=CastDoubleToSSizeT(floor(bounds.x2+0.5));
4980+
poly_extent.y2=CastDoubleToSSizeT(floor(bounds.y2+0.5));
49814981
number_threads=GetMagickNumberThreads(image,image,poly_extent.y2-
49824982
poly_extent.y1+1,1);
49834983
status=AcquirePolygonEdgesTLS(polygon_info,number_threads,&image->exception);
@@ -5022,8 +5022,8 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
50225022
}
50235023
for ( ; x <= poly_extent.x2; x++)
50245024
{
5025-
if ((x == CastDoubleToLong(ceil(primitive_info->point.x-0.5))) &&
5026-
(y == CastDoubleToLong(ceil(primitive_info->point.y-0.5))))
5025+
if ((x == CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5))) &&
5026+
(y == CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5))))
50275027
(void) GetFillColor(draw_info,x-poly_extent.x1,y-poly_extent.y1,q);
50285028
q++;
50295029
}
@@ -5041,8 +5041,8 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
50415041
/*
50425042
Draw polygon or line.
50435043
*/
5044-
poly_extent.y1=CastDoubleToLong(ceil(bounds.y1-0.5));
5045-
poly_extent.y2=CastDoubleToLong(floor(bounds.y2+0.5));
5044+
poly_extent.y1=CastDoubleToSSizeT(ceil(bounds.y1-0.5));
5045+
poly_extent.y2=CastDoubleToSSizeT(floor(bounds.y2+0.5));
50465046
#if defined(MAGICKCORE_OPENMP_SUPPORT)
50475047
#pragma omp parallel for schedule(static) shared(status) \
50485048
num_threads(number_threads)
@@ -5164,8 +5164,8 @@ static void LogPrimitiveInfo(const PrimitiveInfo *primitive_info)
51645164
coordinates,
51655165
y;
51665166

5167-
x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
5168-
y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
5167+
x=CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5));
5168+
y=CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5));
51695169
switch (primitive_info->primitive)
51705170
{
51715171
case PointPrimitive:
@@ -5279,8 +5279,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
52795279
status&=SetImageClipMask(image,draw_info->clipping_mask);
52805280
status&=SetImageMask(image,draw_info->composite_mask);
52815281
}
5282-
x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
5283-
y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
5282+
x=CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5));
5283+
y=CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5));
52845284
image_view=AcquireAuthenticCacheView(image,exception);
52855285
switch (primitive_info->primitive)
52865286
{
@@ -5580,8 +5580,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
55805580
composite_images=DestroyImageList(composite_images);
55815581
(void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor)
55825582
NULL,(void *) NULL);
5583-
x1=CastDoubleToLong(ceil(primitive_info[1].point.x-0.5));
5584-
y1=CastDoubleToLong(ceil(primitive_info[1].point.y-0.5));
5583+
x1=CastDoubleToSSizeT(ceil(primitive_info[1].point.x-0.5));
5584+
y1=CastDoubleToSSizeT(ceil(primitive_info[1].point.y-0.5));
55855585
if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) ||
55865586
((y1 != 0L) && (y1 != (ssize_t) composite_image->rows)))
55875587
{
@@ -6181,7 +6181,7 @@ static MagickBooleanType TraceArcPath(MVGInfo *mvg_info,const PointInfo start,
61816181
else
61826182
if ((theta > 0.0) && (sweep == MagickFalse))
61836183
theta-=2.0*MagickPI;
6184-
arc_segments=(size_t) CastDoubleToLong(ceil(fabs((double) (theta/(0.5*
6184+
arc_segments=(size_t) CastDoubleToSSizeT(ceil(fabs((double) (theta/(0.5*
61856185
MagickPI+MagickEpsilon)))));
61866186
p=primitive_info;
61876187
status=MagickTrue;
@@ -7522,7 +7522,7 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
75227522
theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
75237523
if (theta.q < theta.p)
75247524
theta.q+=2.0*MagickPI;
7525-
arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.q-
7525+
arc_segments=(size_t) CastDoubleToSSizeT(ceil((double) ((theta.q-
75267526
theta.p)/(2.0*sqrt(PerceptibleReciprocal(mid))))));
75277527
CheckPathExtent(MaxStrokePad,arc_segments+MaxStrokePad);
75287528
stroke_q[q].x=box_q[1].x;
@@ -7595,7 +7595,7 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
75957595
theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
75967596
if (theta.p < theta.q)
75977597
theta.p+=2.0*MagickPI;
7598-
arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.p-
7598+
arc_segments=(size_t) CastDoubleToSSizeT(ceil((double) ((theta.p-
75997599
theta.q)/(2.0*sqrt((double) (PerceptibleReciprocal(mid)))))));
76007600
CheckPathExtent(arc_segments+MaxStrokePad,MaxStrokePad);
76017601
stroke_p[p++]=box_p[1];

magick/effect.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ MagickExport Image *AdaptiveBlurImageChannel(const Image *image,
329329
v;
330330

331331
gamma=0.0;
332-
i=CastDoubleToLong(ceil((double) width*QuantumScale*
332+
i=CastDoubleToSSizeT(ceil((double) width*QuantumScale*
333333
GetPixelIntensity(edge_image,r)-0.5));
334334
if (i < 0)
335335
i=0;
@@ -652,7 +652,7 @@ MagickExport Image *AdaptiveSharpenImageChannel(const Image *image,
652652
v;
653653

654654
gamma=0.0;
655-
i=CastDoubleToLong(ceil((double) width*(1.0-QuantumScale*
655+
i=CastDoubleToSSizeT(ceil((double) width*(1.0-QuantumScale*
656656
GetPixelIntensity(edge_image,r))-0.5));
657657
if (i < 0)
658658
i=0;
@@ -2042,9 +2042,9 @@ MagickExport Image *MotionBlurImageChannel(const Image *image,
20422042
point.y=(double) width*cos(DegreesToRadians(angle));
20432043
for (i=0; i < (ssize_t) width; i++)
20442044
{
2045-
offset[i].x=CastDoubleToLong(ceil((double) (i*point.y)/
2045+
offset[i].x=CastDoubleToSSizeT(ceil((double) (i*point.y)/
20462046
hypot(point.x,point.y)-0.5));
2047-
offset[i].y=CastDoubleToLong(ceil((double) (i*point.x)/
2047+
offset[i].y=CastDoubleToSSizeT(ceil((double) (i*point.x)/
20482048
hypot(point.x,point.y)-0.5));
20492049
}
20502050

magick/gem.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ MagickExport void ConvertHWBToRGB(const double hue,const double whiteness,
702702
*blue=ClampToQuantum(QuantumRange*v);
703703
return;
704704
}
705-
i=CastDoubleToLong(floor(6.0*hue));
705+
i=CastDoubleToSSizeT(floor(6.0*hue));
706706
f=6.0*hue-i;
707707
if ((i & 0x01) != 0)
708708
f=1.0-f;

0 commit comments

Comments
 (0)