diff --git a/irr/include/irrTypes.h b/irr/include/irrTypes.h index af5aaec5f..1ad6efc53 100644 --- a/irr/include/irrTypes.h +++ b/irr/include/irrTypes.h @@ -43,14 +43,8 @@ typedef float f32; /** This is a typedef for double, it ensures portability of the engine. */ typedef double f64; -//! Defines for snprintf_irr because snprintf method does not match the ISO C -//! standard on Windows platforms. -//! We want int snprintf_irr(char *str, size_t size, const char *format, ...); -#if defined(_MSC_VER) -#define snprintf_irr sprintf_s -#else +//! Note: cannot assume that positional arguments are supported (not on Windows) #define snprintf_irr snprintf -#endif // _MSC_VER //! Type name for character type used by the file system (legacy). typedef char fschar_t; diff --git a/irr/src/COpenGLCoreTexture.h b/irr/src/COpenGLCoreTexture.h index fd175658a..e4a8d996e 100644 --- a/irr/src/COpenGLCoreTexture.h +++ b/irr/src/COpenGLCoreTexture.h @@ -164,7 +164,7 @@ public: Size = OriginalSize; if (core::min_(Size.Width, Size.Height) == 0 || core::max_(Size.Width, Size.Height) > Driver->MaxTextureSize) { - char buf[64]; + char buf[32]; snprintf_irr(buf, sizeof(buf), "%dx%d", Size.Width, Size.Height); os::Printer::log("Invalid size for render target", buf, ELL_ERROR); return; @@ -187,7 +187,7 @@ public: } #endif - char lbuf[100]; + char lbuf[200]; snprintf_irr(lbuf, sizeof(lbuf), "COpenGLCoreTexture: RTT Type = %d Size = %dx%d (S:%d) ColorFormat = %s -> %#06x %#06x %#06x%s", (int)Type, Size.Width, Size.Height, (int)MSAA, ColorFormatName(ColorFormat), @@ -484,7 +484,7 @@ protected: Size = OriginalSize; if (Size.Width == 0 || Size.Height == 0) { - char buf[64]; + char buf[32]; snprintf_irr(buf, sizeof(buf), "%dx%d", Size.Width, Size.Height); os::Printer::log("Invalid size of image for texture", buf, ELL_ERROR); return; diff --git a/irr/src/OpenGL/Driver.cpp b/irr/src/OpenGL/Driver.cpp index 35538a59b..a03f4d7f3 100644 --- a/irr/src/OpenGL/Driver.cpp +++ b/irr/src/OpenGL/Driver.cpp @@ -139,7 +139,7 @@ void COpenGL3DriverBase::debugCb(GLenum source, GLenum type, GLuint id, GLenum s ll = ELL_ERROR; else if (severity == GL_DEBUG_SEVERITY_MEDIUM) ll = ELL_WARNING; - char buf[300]; + char buf[512]; snprintf_irr(buf, sizeof(buf), "%04x %04x %.*s", source, type, length, message); os::Printer::log("GL", buf, ll); } diff --git a/src/util/string.cpp b/src/util/string.cpp index 52fc3ada9..aeec51cb8 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -1087,7 +1087,7 @@ std::optional my_string_to_double(const std::string &s) char *end = nullptr; // Note: this also supports hexadecimal notation like "0x1.0p+1" double number = std::strtod(s.c_str(), &end); - if (end != &*s.end()) + if (end && *end != '\0') return std::nullopt; return number; }