File tree 1 file changed +3
-4
lines changed
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -68,19 +68,18 @@ auto AllocStringBuffer( LPCSTR str, uint32_t byteLength ) -> BSTR {
68
68
69
69
// Allocating memory for storing the BSTR as a byte array.
70
70
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc, cppcoreguidelines-owning-memory)
71
- auto * bstrBuffer = static_cast < byte_t * >( std::calloc ( bufferSize, sizeof ( byte_t ) ) );
71
+ auto * bstrBuffer = static_cast < bstr_prefix_t * >( std::calloc ( bufferSize, sizeof ( byte_t ) ) );
72
72
73
73
if ( bstrBuffer == nullptr ) { // Failed to allocate memory for the BSTR buffer.
74
74
return nullptr ;
75
75
}
76
76
77
77
// Storing the number of bytes of the BSTR as a prefix of it.
78
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
79
- *reinterpret_cast < bstr_prefix_t * >( bstrBuffer ) = byteLength;
78
+ *bstrBuffer = byteLength;
80
79
81
80
// The actual BSTR must point after the byteLength prefix.
82
81
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic, cppcoreguidelines-pro-type-reinterpret-cast)
83
- BSTR result = reinterpret_cast < BSTR >( bstrBuffer + sizeof ( bstr_prefix_t ) );
82
+ BSTR result = reinterpret_cast < BSTR >( bstrBuffer + 1 );
84
83
if ( str != nullptr ) {
85
84
// Copying byte-by-byte the input string to the BSTR.
86
85
// Note: flawfinder warns about not checking for buffer overflows; this is a false alarm,
You can’t perform that action at this time.
0 commit comments