Skip to content

Commit

Permalink
Fixed out of bounds error in SpliceImage.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Oct 9, 2015
1 parent 0ccbde8 commit 7b1cf57
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions MagickCore/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,7 @@ MagickExport Image *SpliceImage(const Image *image,
splice_geometry;

ssize_t
columns,
y;

/*
Expand Down Expand Up @@ -1810,6 +1811,7 @@ MagickExport Image *SpliceImage(const Image *image,
*/
status=MagickTrue;
progress=0;
columns=MagickMin(splice_geometry.x,(ssize_t) splice_image->columns);
image_view=AcquireVirtualCacheView(image,exception);
splice_view=AcquireAuthenticCacheView(splice_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
Expand All @@ -1829,15 +1831,16 @@ MagickExport Image *SpliceImage(const Image *image,

if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
p=GetCacheViewVirtualPixels(image_view,0,y,splice_image->columns,1,
exception);
q=QueueCacheViewAuthenticPixels(splice_view,0,y,splice_image->columns,1,
exception);
if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
{
status=MagickFalse;
continue;
}
for (x=0; x < splice_geometry.x; x++)
for (x=0; x < columns; x++)
{
register ssize_t
i;
Expand Down Expand Up @@ -1931,18 +1934,18 @@ MagickExport Image *SpliceImage(const Image *image,

if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y-(ssize_t) splice_geometry.height,
image->columns,1,exception);
if ((y < 0) || (y >= (ssize_t) splice_image->rows))
if ((y < 0) || (y >= (ssize_t)splice_image->rows))
continue;
p=GetCacheViewVirtualPixels(image_view,0,y-(ssize_t) splice_geometry.height,
splice_image->columns,1,exception);
q=QueueCacheViewAuthenticPixels(splice_view,0,y,splice_image->columns,1,
exception);
if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
{
status=MagickFalse;
continue;
}
for (x=0; x < splice_geometry.x; x++)
for (x=0; x < columns; x++)
{
register ssize_t
i;
Expand Down

0 comments on commit 7b1cf57

Please sign in to comment.