File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -5195,17 +5195,33 @@ static MagickBooleanType WriteSVGImage(const ImageInfo *image_info,Image *image)
51955195 }
51965196 case PathPrimitive :
51975197 {
5198- int
5199- number_attributes ;
5198+ size_t
5199+ number_attributes ,
5200+ quantum ;
52005201
52015202 (void ) GetNextToken (q ,& q ,extent ,token );
52025203 number_attributes = 1 ;
52035204 for (p = token ; * p != '\0' ; p ++ )
52045205 if (isalpha ((int ) * p ))
52055206 number_attributes ++ ;
5206- if (i > ( ssize_t ) ( number_points - 6 * BezierQuantum * number_attributes - 1 ))
5207+ if (( 6 * BezierQuantum ) >= ( MAGICK_SSIZE_MAX / number_attributes ))
52075208 {
5208- number_points += 6 * BezierQuantum * number_attributes ;
5209+ (void ) ThrowMagickException (& image -> exception ,GetMagickModule (),
5210+ ResourceLimitError ,"MemoryAllocationFailed" ,"`%s'" ,
5211+ image -> filename );
5212+ break ;
5213+ }
5214+ quantum = (size_t ) 6 * BezierQuantum * number_attributes ;
5215+ if (number_points >= (MAGICK_SSIZE_MAX - quantum ))
5216+ {
5217+ (void ) ThrowMagickException (& image -> exception ,GetMagickModule (),
5218+ ResourceLimitError ,"MemoryAllocationFailed" ,"`%s'" ,
5219+ image -> filename );
5220+ break ;
5221+ }
5222+ if (i > (ssize_t ) (number_points - quantum - 1 ))
5223+ {
5224+ number_points += quantum ;
52095225 primitive_info = (PrimitiveInfo * ) ResizeQuantumMemory (primitive_info ,
52105226 number_points ,sizeof (* primitive_info ));
52115227 if (primitive_info == (PrimitiveInfo * ) NULL )
You can’t perform that action at this time.
0 commit comments