Skip to content

Commit

Permalink
Continue to follow partial suggestions from mingkuang.
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Jun 23, 2024
1 parent 5387d97 commit c1685b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/Shared/hstring_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,30 @@ namespace YY::Thunks::internal
} HSTRING_HEADER_INTERNAL, *PHSTRING_HEADER_INTERNAL;
static_assert(sizeof(HSTRING_HEADER) == sizeof(HSTRING_HEADER_INTERNAL));

#ifdef _MSC_VER
#if (_MSC_VER >= 1200)
#pragma warning(push)
#endif
#pragma warning(disable:4200) // zero length array
#endif

/*
* @brief The internal structure of heap allocated Windows Runtime String.
*/
typedef struct _STRING_OPAQUE
{
HSTRING_HEADER_INTERNAL Header;
volatile INT RefCount;
WCHAR String[ANYSIZE_ARRAY];
WCHAR String[0];
} STRING_OPAQUE, *PSTRING_OPAQUE;

#ifdef _MSC_VER
#if (_MSC_VER >= 1200)
#pragma warning(pop)
#else
#pragma warning(default:4200) // zero length array
#endif
#endif
}

#endif // !YY_THUNKS_HSTRING_PRIVATE
2 changes: 1 addition & 1 deletion src/Thunks/api-ms-win-core-winrt-string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace YY::Thunks
return E_POINTER;
}

SIZE_T RequiredSize = sizeof(internal::STRING_OPAQUE) + length * sizeof(WCHAR);
SIZE_T RequiredSize = sizeof(internal::STRING_OPAQUE) + (length + 1) * sizeof(WCHAR);
if (MAXUINT32 < RequiredSize)
{
return MEM_E_INVALID_SIZE;
Expand Down

0 comments on commit c1685b2

Please sign in to comment.