From 3e30927c450e509543758257ae313dcd33be2c15 Mon Sep 17 00:00:00 2001 From: MrKrzYch00 Date: Thu, 7 Apr 2016 03:14:51 +0200 Subject: [PATCH] Fix crash with --prefix Occurs most likely when certain g++ optimizations are enabled, so this code needs to be split into parts to make sure we don't run into false-positive Issue reports when some user tries out some compiler optimizations. --- src/zopflipng/zopflipng_bin.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/zopflipng/zopflipng_bin.cc b/src/zopflipng/zopflipng_bin.cc index 9fbce0f3..4a65d26c 100644 --- a/src/zopflipng/zopflipng_bin.cc +++ b/src/zopflipng/zopflipng_bin.cc @@ -356,7 +356,10 @@ int main(int argc, char *argv[]) { if (use_prefix) { std::string dir, file, ext; GetFileNameParts(files[i], &dir, &file, &ext); - out_filename = dir + prefix + file + ext; + out_filename = dir; + out_filename += prefix; + out_filename += file; + out_filename += ext; } bool different_output_name = out_filename != files[i];