normal default truncated modulo division.
*/
modulo.quotient=offset/(ssize_t) extent;
- if ((offset < 0L) && (modulo.quotient != INT64_MIN))
+ if ((offset < 0L) && (modulo.quotient > (ssize_t) (-SSIZE_MAX)))
modulo.quotient--;
modulo.remainder=(ssize_t) (offset-(double) modulo.quotient*extent);
return(modulo);
assert(cache_info->signature == MagickCoreSignature);
if (cache_info->type == UndefinedCache)
return((Quantum *) NULL);
- if ((region->width == 0) || (region->height == 0))
- return((Quantum *) NULL);
- nexus_info->region=(*region);
- number_pixels=(MagickSizeType) nexus_info->region.width*
- nexus_info->region.height;
- if (number_pixels == 0)
- return((Quantum *) NULL);
if (((cache_info->type == MemoryCache) || (cache_info->type == MapCache)) &&
(buffered == MagickFalse))
{
x,
y;
- x=nexus_info->region.x+(ssize_t) nexus_info->region.width-1;
- y=nexus_info->region.y+(ssize_t) nexus_info->region.height-1;
- if (((nexus_info->region.x >= 0) && (nexus_info->region.y >= 0) &&
- (y < (ssize_t) cache_info->rows)) &&
- (((nexus_info->region.x == 0) &&
- (nexus_info->region.width == cache_info->columns)) ||
- ((nexus_info->region.height == 1) &&
- (x < (ssize_t) cache_info->columns))))
+ x=(ssize_t) region->width+region->x-1;
+ y=(ssize_t) region->height+region->y-1;
+ if (((region->x >= 0) &&
+ (region->y >= 0) && (y < (ssize_t) cache_info->rows)) &&
+ (((region->x == 0) && (region->width == cache_info->columns)) ||
+ ((region->height == 1) && (x < (ssize_t) cache_info->columns))))
{
MagickOffsetType
offset;
/*
Pixels are accessed directly from memory.
*/
- offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
- nexus_info->region.x;
+ offset=(MagickOffsetType) region->y*cache_info->columns+region->x;
nexus_info->pixels=cache_info->pixels+cache_info->number_channels*
offset;
nexus_info->metacontent=(void *) NULL;
if (cache_info->metacontent_extent != 0)
nexus_info->metacontent=(unsigned char *) cache_info->metacontent+
offset*cache_info->metacontent_extent;
+ nexus_info->region=(*region);
nexus_info->authentic_pixel_cache=MagickTrue;
PrefetchPixelCacheNexusPixels(nexus_info,mode);
return(nexus_info->pixels);
/*
Pixels are stored in a staging region until they are synced to the cache.
*/
- length=number_pixels*cache_info->number_channels*sizeof(*nexus_info->pixels);
+ number_pixels=(MagickSizeType) region->width*region->height;
+ length=MagickMax(number_pixels,cache_info->columns)*
+ cache_info->number_channels*sizeof(*nexus_info->pixels);
if (cache_info->metacontent_extent != 0)
length+=number_pixels*cache_info->metacontent_extent;
if (nexus_info->cache == (Quantum *) NULL)
{
status=AcquireCacheNexusPixels(cache_info,length,nexus_info,exception);
if (status == MagickFalse)
- return((Quantum *) NULL);
+ {
+ (void) memset(&nexus_info->region,0,sizeof(nexus_info->region));
+ return((Quantum *) NULL);
+ }
}
else
if (nexus_info->length < length)
RelinquishCacheNexusPixels(nexus_info);
status=AcquireCacheNexusPixels(cache_info,length,nexus_info,exception);
if (status == MagickFalse)
- return((Quantum *) NULL);
+ {
+ (void) memset(&nexus_info->region,0,sizeof(nexus_info->region));
+ return((Quantum *) NULL);
+ }
}
nexus_info->pixels=nexus_info->cache;
nexus_info->metacontent=(void *) NULL;
if (cache_info->metacontent_extent != 0)
nexus_info->metacontent=(void *) (nexus_info->pixels+
cache_info->number_channels*number_pixels);
+ nexus_info->region=(*region);
nexus_info->authentic_pixel_cache=cache_info->type == PingCache ?
MagickTrue : MagickFalse;
PrefetchPixelCacheNexusPixels(nexus_info,mode);