diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 617b487d2d..ef38df35e0 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1342,7 +1342,7 @@ public: inline unsigned layers() const { return layers_rst_.size(); } inline void drawPolygon(const ExPolygon& p, unsigned lyr) { - assert(lyr_id < layers_rst_.size()); + assert(lyr < layers_rst_.size()); layers_rst_[lyr].first.draw(p); } diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index ab83c5ec6d..ff5b95c352 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -16,12 +16,6 @@ #include // For png compression -//#if !((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) -//inline char *strerror_r(int errnum, char *buf, size_t buflen) { -// strerror_s(buf, buflen, errnum); -// return buf; -//} -//#endif #include namespace Slic3r { diff --git a/xs/src/png/error.hpp b/xs/src/png/error.hpp index f7d6d7b5f1..c67f97630b 100644 --- a/xs/src/png/error.hpp +++ b/xs/src/png/error.hpp @@ -94,20 +94,27 @@ namespace png static std::string thread_safe_strerror(int errnum) { #define ERRBUF_SIZE 512 - char buf[ERRBUF_SIZE] = { 0 }; -//#ifdef HAVE_STRERROR_S +#ifdef HAVE_STRERROR_S + char buf[ERRBUF_SIZE] = { 0 }; strerror_s(buf, ERRBUF_SIZE, errnum); return std::string(buf); -//#else -//#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE -// strerror_r(errnum, buf, ERRBUF_SIZE); -// return std::string(buf); -//#else -// /* GNU variant can return a pointer to static buffer instead of buf */ -// return std::string(strerror_r(errnum, buf, ERRBUF_SIZE)); -//#endif -//#endif +#else +#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE + char buf[ERRBUF_SIZE] = { 0 }; + strerror_r(errnum, buf, ERRBUF_SIZE); + return std::string(buf); +#elif _GNU_SOURCE + /* GNU variant can return a pointer to static buffer instead of buf */ + char buf[ERRBUF_SIZE] = { 0 }; + return std::string(strerror_r(errnum, buf, ERRBUF_SIZE)); +#else + return std::string("An error occured with errnum ") + + std::to_string(errnum) + + ". Converting to the appropriate error message is disabled" + "in this instance of the png++ library."; +#endif +#endif #undef ERRBUF_SIZE }