From b40e8c942764e4923d6ef31767ea2949b8a1e22b Mon Sep 17 00:00:00 2001 From: Nicolas Guillemot Date: Sat, 2 Apr 2016 15:15:29 -0700 Subject: [PATCH] use sscanf_s in MSVC consistent with other uses of sscanf in the library --- tiny_obj_loader.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tiny_obj_loader.h b/tiny_obj_loader.h index 826ec24..b039c40 100644 --- a/tiny_obj_loader.h +++ b/tiny_obj_loader.h @@ -1089,7 +1089,11 @@ bool LoadObj(std::vector &shapes, // [output] char namebuf[4096]; token += 2; +#ifdef _MSC_VER + sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); +#else sscanf(token, "%s", namebuf); +#endif tag.name = std::string(namebuf); token += tag.name.size() + 1; @@ -1113,7 +1117,11 @@ bool LoadObj(std::vector &shapes, // [output] for (size_t i = 0; i < static_cast(ts.num_strings); ++i) { char stringValueBuffer[4096]; +#ifdef _MSC_VER + sscanf_s(token, "%s", stringValueBuffer, (unsigned)_countof(stringValueBuffer)); +#else sscanf(token, "%s", stringValueBuffer); +#endif tag.stringValues[i] = stringValueBuffer; token += tag.stringValues[i].size() + 1; }