]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/1721
authorCristy <urban-warrior@imagemagick.org>
Sat, 5 Oct 2019 12:55:54 +0000 (08:55 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 5 Oct 2019 12:55:54 +0000 (08:55 -0400)
MagickCore/string.c

index 62056e739b6659dab292d0724c05973b2d721932..63fae8113b5514a64f475645a8d36c27eb6394bc 100644 (file)
@@ -2592,7 +2592,7 @@ MagickExport MagickBooleanType SubstituteString(char **string,
   {
     if (search_extent == 0)
       search_extent=strlen(search);
-    if (strncmp(p,search,search_extent) != 0)
+    if ((*p == *search) && (strncmp(p,search,search_extent) != 0))
       continue;
     /*
       We found a match.
@@ -2620,7 +2620,9 @@ MagickExport MagickBooleanType SubstituteString(char **string,
       (void) memmove(p+replace_extent,p+search_extent,
         strlen(p+search_extent)+1);
     (void) memcpy(p,replace,replace_extent);
-    p+=replace_extent-1;
+    p+=replace_extent;
+    if (replace_extent != 0)
+      p--;
   }
   return(status);
 }