]> granicus.if.org Git - imagemagick/commitdiff
Fallback to extension when the filename does not start with clusterfuzz-testcase-
authorDirk Lemstra <dirk@git.imagemagick.org>
Fri, 16 Mar 2018 10:37:43 +0000 (11:37 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Fri, 16 Mar 2018 10:37:43 +0000 (11:37 +0100)
Magick++/fuzz/encoder_format.h
Magick++/fuzz/main.cc

index e30c142325326ce452e2e9d5b354a22d60ea107c..e8484905345e94386c275bbe022071713caf4ae7 100644 (file)
@@ -1,8 +1,15 @@
 class EncoderFormat {
 public:
   std::string get() { return std::string(_format.begin(), _format.end()); } const
-  void set(const std::wstring fileName)
+  void set(const std::wstring fileName, const std::wstring extension)
   {
+    if (fileName.find(L"clusterfuzz-testcase-") != 0)
+    {
+      if (extension.length() > 1)
+        _format = extension.substr(1, extension.size() - 1);
+      return;
+    }
+
     std::wstring format=fileName;
 
     size_t index = format.find(L"_", 0);
index bfc3e7092de3deb7aa29cbbc5385d0c3fcca4e03..2cef193a93a07ad3d22a781c35755dead23bc742 100644 (file)
@@ -35,7 +35,7 @@ public:
     file.read(_data, size);
     file.close();
 
-    encoderFormat.set(fileName);
+    encoderFormat.set(fileName, wstring(PathFindExtension(fileName.c_str())));
 
     return(true);
   }