From 5fa0354cd81ae1c0c92821e0f527ef90bbbdb87a Mon Sep 17 00:00:00 2001 From: Gaurav Date: Tue, 20 Oct 2015 14:54:48 +0530 Subject: [PATCH] Check return value of sprintf again. At other places return value of sprintf is checked, but missed here. --- src/posix_api.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/posix_api.cpp b/src/posix_api.cpp index 8a803b3c..4640ea13 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -185,10 +185,12 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* } } #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) - (::sprintf_s)(localbuf, 5, "%d", 0); + int r = (::sprintf_s)(localbuf, 5, "%d", 0); #else - (std::sprintf)(localbuf, "%d", 0); + int r = (std::sprintf)(localbuf, "%d", 0); #endif + if(r < 0) + return 0; // sprintf failed if(std::strlen(localbuf) < buf_size) re_detail::strcpy_s(buf, buf_size, localbuf); return std::strlen(localbuf) + 1;