From 5b103116c5b6215f7508746dab582b2378088fb6 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 3 Feb 2020 09:24:58 +0100 Subject: [PATCH 1/4] Added missed include under OSX --- src/slic3r/GUI/BitmapCache.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/GUI/BitmapCache.hpp b/src/slic3r/GUI/BitmapCache.hpp index 255cf5495..dd3e6ffc0 100644 --- a/src/slic3r/GUI/BitmapCache.hpp +++ b/src/slic3r/GUI/BitmapCache.hpp @@ -1,6 +1,8 @@ #ifndef SLIC3R_GUI_BITMAP_CACHE_HPP #define SLIC3R_GUI_BITMAP_CACHE_HPP +#include + #include #ifndef WX_PRECOMP #include From e50825ce05510396d2bcf510cb631ada6de47bda Mon Sep 17 00:00:00 2001 From: Slic3rPE Date: Mon, 3 Feb 2020 10:13:15 +0100 Subject: [PATCH 2/4] missing includes --- src/slic3r/GUI/GLCanvas3DManager.cpp | 1 + src/slic3r/GUI/GUI_ObjectList.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/slic3r/GUI/GLCanvas3DManager.cpp b/src/slic3r/GUI/GLCanvas3DManager.cpp index 3594e85a4..a5d75d601 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index fc02c706e..3b51c1761 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include From 8aec5f6726ff0fcfa7eb8838c400e6338571e5ae Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 3 Feb 2020 11:06:49 +0100 Subject: [PATCH 3/4] string_printf Wformat-security hack # #3594, #3592 --- src/libslic3r/libslic3r.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index 0454644bb..7d9558f1e 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -231,16 +231,17 @@ static inline bool is_approx(Number value, Number test_value) } template -std::string string_printf(const char *const fmt, Args &&...args) +std::string string_printf(const char *const _fmt, Args &&...args) { static const size_t INITIAL_LEN = 1024; std::vector buffer(INITIAL_LEN, '\0'); - int bufflen = snprintf(buffer.data(), INITIAL_LEN - 1, fmt, std::forward(args)...); + auto fmt = std::string("%s") + _fmt; + int bufflen = snprintf(buffer.data(), INITIAL_LEN - 1, fmt.c_str(), "", std::forward(args)...); if (bufflen >= int(INITIAL_LEN)) { buffer.resize(size_t(bufflen) + 1); - snprintf(buffer.data(), buffer.size(), fmt, std::forward(args)...); + snprintf(buffer.data(), buffer.size(), fmt.c_str(), "", std::forward(args)...); } return std::string(buffer.begin(), buffer.begin() + bufflen); From 992a0c3d7a91ba59ebb14cb35cbd558626e95235 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 3 Feb 2020 11:18:33 +0100 Subject: [PATCH 4/4] remove duplicate string_printf #3594, #3592 --- src/libslic3r/Utils.hpp | 2 -- src/libslic3r/utils.cpp | 18 ------------------ 2 files changed, 20 deletions(-) diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 06c435809..bc6aa20fc 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -93,8 +93,6 @@ namespace PerlUtils { extern std::string path_to_parent_path(const char *src); }; -std::string string_printf(const char *format, ...); - // Standard "generated by Slic3r version xxx timestamp xxx" header string, // to be placed at the top of Slic3r generated files. std::string header_slic3r_generated(); diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index f91d32d28..9f0afa061 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -577,24 +577,6 @@ namespace PerlUtils { std::string path_to_parent_path(const char *src) { return boost::filesystem::path(src).parent_path().string(); } }; - -std::string string_printf(const char *format, ...) -{ - va_list args1; - va_start(args1, format); - va_list args2; - va_copy(args2, args1); - - size_t needed_size = ::vsnprintf(nullptr, 0, format, args1) + 1; - va_end(args1); - - std::string res(needed_size, '\0'); - ::vsnprintf(&res.front(), res.size(), format, args2); - va_end(args2); - - return res; -} - std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_APP_NAME " " SLIC3R_VERSION " on " ) + Utils::utc_timestamp();