diff --git a/snippets/ArrayWrapper1D.hpp b/snippets/ArrayWrapper1D.hpp index ea7f681..97a5f51 100644 --- a/snippets/ArrayWrapper1D.hpp +++ b/snippets/ArrayWrapper1D.hpp @@ -46,14 +46,14 @@ public: template ::value, int>::type = 0> operator std::string() const { - return std::string( this->data(), N ); + return std::string( this->data(), strnlen( this->data(), N ) ); } #if 17 <= VULKAN_HPP_CPP_VERSION template ::value, int>::type = 0> operator std::string_view() const { - return std::string_view( this->data(), N ); + return std::string_view( this->data(), strnlen( this->data(), N ) ); } #endif diff --git a/snippets/includes.hpp b/snippets/includes.hpp index 8d3bb20..2aeb0f2 100644 --- a/snippets/includes.hpp +++ b/snippets/includes.hpp @@ -2,8 +2,9 @@ #define VULKAN_HPP #include -#include // ArrayWrapperND -#include // std::string +#include // ArrayWrapperND +#include // std::string +#include // strnlen #include #include diff --git a/tests/ArrayWrapper/ArrayWrapper.cpp b/tests/ArrayWrapper/ArrayWrapper.cpp index 2a3963c..1a32fe6 100644 --- a/tests/ArrayWrapper/ArrayWrapper.cpp +++ b/tests/ArrayWrapper/ArrayWrapper.cpp @@ -28,7 +28,7 @@ int main( int /*argc*/, char ** /*argv*/ ) { vk::ArrayWrapper1D aw1( { 'f', 'o', 'o', 'b', 'a', 'h' } ); std::string s1 = aw1; - assert( s1.length() == 10 ); + assert( s1.length() == 6 ); std::cout << "<" << aw1 << ">" << std::endl; // s1 = aw1; // 'operator =' is ambiguous @@ -51,9 +51,9 @@ int main( int /*argc*/, char ** /*argv*/ ) std::cout << std::boolalpha << std::is_convertible_v, std::string_view> << std::endl; std::string_view sv1 = aw1; - assert( sv1.size() == 10 ); + assert( sv1.size() == 6 ); sv1 = aw2; - assert( sv1.size() == 20 ); + assert( sv1.size() == 6 ); sv1 = aw3; assert( sv1.size() == 5 ); diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 814e352..8f0d7d9 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -9,8 +9,9 @@ #define VULKAN_HPP #include -#include // ArrayWrapperND -#include // std::string +#include // ArrayWrapperND +#include // strnlen +#include // std::string #include #include @@ -134,14 +135,14 @@ namespace VULKAN_HPP_NAMESPACE template ::value, int>::type = 0> operator std::string() const { - return std::string( this->data(), N ); + return std::string( this->data(), strnlen( this->data(), N ) ); } #if 17 <= VULKAN_HPP_CPP_VERSION template ::value, int>::type = 0> operator std::string_view() const { - return std::string_view( this->data(), N ); + return std::string_view( this->data(), strnlen( this->data(), N ) ); } #endif @@ -15996,7 +15997,7 @@ namespace VULKAN_HPP_NAMESPACE # elif defined( __APPLE__ ) m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); # elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); + m_library = ::LoadLibraryA( "vulkan-1.dll" ); # else # error unsupported platform # endif diff --git a/vulkan/vulkansc.hpp b/vulkan/vulkansc.hpp index f188f41..73eae1a 100644 --- a/vulkan/vulkansc.hpp +++ b/vulkan/vulkansc.hpp @@ -9,8 +9,9 @@ #define VULKAN_HPP #include -#include // ArrayWrapperND -#include // std::string +#include // ArrayWrapperND +#include // strnlen +#include // std::string #include #include @@ -134,14 +135,14 @@ namespace VULKAN_HPP_NAMESPACE template ::value, int>::type = 0> operator std::string() const { - return std::string( this->data(), N ); + return std::string( this->data(), strnlen( this->data(), N ) ); } #if 17 <= VULKAN_HPP_CPP_VERSION template ::value, int>::type = 0> operator std::string_view() const { - return std::string_view( this->data(), N ); + return std::string_view( this->data(), strnlen( this->data(), N ) ); } #endif @@ -6956,7 +6957,7 @@ namespace VULKAN_HPP_NAMESPACE # elif defined( __APPLE__ ) m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL ); # elif defined( _WIN32 ) - m_library = ::LoadLibraryA( "vulkan-1.dll" ); + m_library = ::LoadLibraryA( "vulkan-1.dll" ); # else # error unsupported platform # endif