Skip to content

Commit 11a136f

Browse files
authored
Merge pull request #286 from petermarko/fix/reinterpret-cast
Fix arm alignment compiler errors
2 parents 3006581 + b2789ea commit 11a136f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/internal/windows.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,18 @@ auto AllocStringBuffer( LPCSTR str, uint32_t byteLength ) -> BSTR {
6868

6969
// Allocating memory for storing the BSTR as a byte array.
7070
// 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 ) ) );
7272

7373
if ( bstrBuffer == nullptr ) { // Failed to allocate memory for the BSTR buffer.
7474
return nullptr;
7575
}
7676

7777
// 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;
8079

8180
// The actual BSTR must point after the byteLength prefix.
8281
// 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 );
8483
if ( str != nullptr ) {
8584
// Copying byte-by-byte the input string to the BSTR.
8685
// Note: flawfinder warns about not checking for buffer overflows; this is a false alarm,

0 commit comments

Comments
 (0)