ver allocate memory, typically used when concatentating strings

This commit is contained in:
Cristy
2021-06-19 11:11:37 -04:00
parent 85ae49e52b
commit dfbf466c79
4 changed files with 37 additions and 9 deletions
+17 -5
View File
@@ -479,8 +479,8 @@ MagickExport MagickBooleanType ConcatenateString(
length+=source_length;
if (~length < MagickPathExtent)
ThrowFatalException(ResourceLimitFatalError,"UnableToConcatenateString");
*destination=(char *) ResizeQuantumMemory(*destination,length+
MagickPathExtent,sizeof(**destination));
*destination=(char *) ResizeQuantumMemory(*destination,
OverAllocateMemory(length+MagickPathExtent),sizeof(**destination));
if (*destination == (char *) NULL)
ThrowFatalException(ResourceLimitFatalError,"UnableToConcatenateString");
if (source_length != 0)
@@ -527,7 +527,19 @@ MagickExport void ConcatenateStringInfo(StringInfo *string_info,
length=string_info->length;
if (~length < source->length)
ThrowFatalException(ResourceLimitFatalError,"UnableToConcatenateString");
SetStringInfoLength(string_info,length+source->length);
length+=source->length;
if (~length < MagickPathExtent)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
string_info->length=length;
if (string_info->datum == (unsigned char *) NULL)
string_info->datum=(unsigned char *) AcquireQuantumMemory(length+
MagickPathExtent,sizeof(*string_info->datum));
else
string_info->datum=(unsigned char *) ResizeQuantumMemory(
string_info->datum,OverAllocateMemory(length+MagickPathExtent),
sizeof(*string_info->datum));
if (string_info->datum == (unsigned char *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) memcpy(string_info->datum+length,source->datum,source->length);
}
@@ -2611,8 +2623,8 @@ MagickExport MagickBooleanType SubstituteString(char **string,
*/
offset=(ssize_t) (p-(*string));
extent=strlen(*string)+replace_extent-search_extent+1;
*string=(char *) ResizeQuantumMemory(*string,extent+MagickPathExtent,
sizeof(*p));
*string=(char *) ResizeQuantumMemory(*string,
OverAllocateMemory(extent+MagickPathExtent),sizeof(*p));
if (*string == (char *) NULL)
ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
p=(*string)+offset;