mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-25 21:40:04 +00:00
Switch from using strncpy to strncpy_s. (#1809)
This commit is contained in:
parent
38e3e8f800
commit
4c130b9051
@ -10722,16 +10722,13 @@ std::string VulkanHppGenerator::generateStructConstructorsEnhanced( std::pair<st
|
||||
assert( mit->arraySizes.size() == 1 );
|
||||
static const std::string copyOpsTemplate = R"(
|
||||
VULKAN_HPP_ASSERT( ${memberName}_.size() < ${arraySize} );
|
||||
${copyOp}( ${memberName}, ${memberName}_.data(), ${arraySizeExpression} );)";
|
||||
${copyOp}( ${memberName}, ${memberSize}, ${memberName}_.data(), ${memberName}_.size() );)";
|
||||
|
||||
std::string arraySizeExpression = ( mit->lenExpressions[0] == "null-terminated" )
|
||||
? ( "std::min<size_t>( " + mit->name + "_.size(), " + mit->arraySizes[0] + " )" )
|
||||
: ( mit->lenExpressions[0] + " * sizeof( " + argumentType + " )" );
|
||||
copyOps += replaceWithMap( copyOpsTemplate,
|
||||
{ { "arraySize", mit->arraySizes[0] },
|
||||
{ "arraySizeExpression", arraySizeExpression },
|
||||
{ "copyOp", mit->lenExpressions[0] == "null-terminated" ? "strncpy" : "memcpy" },
|
||||
{ "memberName", mit->name } } );
|
||||
{ "copyOp", mit->lenExpressions[0] == "null-terminated" ? "strncpy_s" : "memcpy_s" },
|
||||
{ "memberName", mit->name },
|
||||
{ "memberSize", mit->arraySizes[0] } } );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -11450,7 +11447,7 @@ std::string VulkanHppGenerator::generateStructSetter( std::string const & struct
|
||||
${structureName} & set${ArrayName}( std::string const & ${arrayName}_ ) VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
VULKAN_HPP_ASSERT( ${arrayName}_.size() < ${arraySize} );
|
||||
strncpy( ${arrayName}, ${arrayName}_.data(), std::min<size_t>( ${arrayName}_.size(), ${arraySize} ) );
|
||||
strncpy_s( ${arrayName}, ${arraySize}, ${arrayName}_.data(), ${arrayName}_.size() );
|
||||
return *this;
|
||||
}
|
||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||
|
Loading…
Reference in New Issue
Block a user