if (HeapOverflowSanityCheck(count,quantum) != MagickFalse)
return((MemoryInfo *) NULL);
- if (max_memory_request == 0)
- {
- max_memory_request=(size_t) MagickULLConstant(~0);
- value=GetPolicyValue("system:max-memory-request");
- if (value != (char *) NULL)
- {
- /*
- The security policy sets a max memory request limit.
- */
- max_memory_request=StringToSizeType(value,100.0);
- value=DestroyString(value);
- }
- }
+ (void) GetMaxMemoryRequest();
if (virtual_anonymous_memory == 0)
{
virtual_anonymous_memory=1;
% %
% %
% %
++ G e t M a x M e m o r y R e q u e s t %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% GetMaxMemoryRequest() returns the max_memory_request value.
+%
+% The format of the GetMaxMemoryRequest method is:
+%
+% size_t GetMaxMemoryRequest(void)
+%
+*/
+MagickExport size_t GetMaxMemoryRequest(void)
+{
+ if (max_memory_request == 0)
+ {
+ char
+ *value;
+
+ max_memory_request=(size_t) MagickULLConstant(~0);
+ value=GetPolicyValue("system:max-memory-request");
+ if (value != (char *) NULL)
+ {
+ /*
+ The security policy sets a max memory request limit.
+ */
+ max_memory_request=StringToSizeType(value,100.0);
+ value=DestroyString(value);
+ }
+ }
+ return(max_memory_request);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% G e t V i r t u a l M e m o r y B l o b %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% ResetMaxMemoryRequest() resets the anonymous_memory value.
+% ResetMaxMemoryRequest() resets the max_memory_request value.
%
% The format of the ResetMaxMemoryRequest method is:
%
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% ResetVirtualAnonymousMemory() resets the anonymous_memory value.
+% ResetVirtualAnonymousMemory() resets the virtual_anonymous_memory value.
%
% The format of the ResetVirtualAnonymousMemory method is:
%
size_t
extent;
+ (void) context;
if (HeapOverflowSanityCheck(items,size) != MagickFalse)
return((void *) NULL);
extent=items*size;
- /* Check if the buffer is big enough when we get a large request */
- if ((context != (void *) NULL) && (extent > 2000000))
- {
- Image
- *image;
-
- image=(Image *) context;
- if ((MagickSizeType) extent > GetBlobSize(image))
- return((void *) NULL);
- }
+ if (extent > GetMaxMemoryRequest())
+ return((void *) NULL);
return(AcquireMagickMemory(extent));
}
if (length == 0)
{
count=ReadBlob(image,packet_size,pixels);
- if (count != packet_size)
+ if (count != (ssize_t) packet_size)
ThrowMIFFException(CorruptImageError,"UnableToReadImageData");
PushRunlengthPacket(image,pixels,&length,&pixel,exception);
}
default:
{
count=ReadBlob(image,packet_size*image->columns,pixels);
- if (count != (packet_size*image->columns))
+ if (count != (ssize_t) (packet_size*image->columns))
ThrowMIFFException(CorruptImageError,"UnableToReadImageData");
(void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
quantum_type,pixels,exception);