summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-19 07:06:47 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-19 07:06:47 -0700
commit208e2cf0432a0f2865a225a9dc51917191c6cd04 (patch)
treefc5627bd17ec4e714664bb227235455ab487eac2
parent867bd2583bf0abc374a096a8c4f41b9b1f38d3a4 (diff)
Change PUGI__SNPRINTF to use _countof for MSVC
The macro only works correctly when the input argument is an array with a statically known size - pointers or arrays decayed to pointers won't work silently. While this is unlikely to surface issues that aren't caught in tests/code review, use _countof for MSVC to prevent such code from compiling.
-rw-r--r--src/pugixml.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 4bc971b..e047822 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -131,7 +131,7 @@ using std::memset;
#if __cplusplus >= 201103
# define PUGI__SNPRINTF(buf, ...) snprintf(buf, sizeof(buf), __VA_ARGS__)
#elif defined(_MSC_VER) && _MSC_VER >= 1400
-# define PUGI__SNPRINTF(buf, ...) _snprintf_s(buf, sizeof(buf), _TRUNCATE, __VA_ARGS__)
+# define PUGI__SNPRINTF(buf, ...) _snprintf_s(buf, _countof(buf), _TRUNCATE, __VA_ARGS__)
#else
# define PUGI__SNPRINTF sprintf
#endif