Merged PR 5769: Replace incorrect sizeof() with strlen() in compiler version test

Replace incorrect sizeof() with strlen() in compiler version test

This would produce a failure only on x86 because it sizeof() gave the size
of a pointer, which just so happens to be the hard coded size of the hash
on x64. On x86, it would advance only 4 bytes, and fail the comparison.

This also checks to see if the VersionStringListSizeInBytes is > 2 more than the hash size, because both null-terminators are always added, so it will always be at least 2 more, even with no CustomVersionString.
This commit is contained in:
Tex Riddell 2023-06-21 17:31:52 +00:00
Родитель 7f6d946c4b
Коммит 657d13ca74
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -2110,10 +2110,12 @@ TEST_F(DxilContainerTest, DxilContainerCompilerVersionTest) {
if (pDCV->VersionStringListSizeInBytes != 0) {
LPCSTR pCommitHashStr = (LPCSTR)pDCV + sizeof(hlsl::DxilCompilerVersion);
uint32_t uCommitHashLen = (uint32_t)strlen(pCommitHashStr);
VERIFY_ARE_EQUAL_STR(pCommitHashStr, pCommitHashRef);
if (pDCV->VersionStringListSizeInBytes > sizeof(pCommitHashStr) + 1) {
LPCSTR pCustomVersionString = pCommitHashStr + sizeof(pCommitHashStr) + 1;
// + 2 for the two null terminators that are included in this size:
if (pDCV->VersionStringListSizeInBytes > uCommitHashLen + 2) {
LPCSTR pCustomVersionString = pCommitHashStr + uCommitHashLen + 1;
VERIFY_ARE_EQUAL_STR(pCustomVersionString, pCustomVersionStrRef)
}
}