Skip to content

Commit

Permalink
assembler: ensure progress when seeking the version string (KhronosGr…
Browse files Browse the repository at this point in the history
…oup#5910)

When trying to parse SPIR-V version from assembly comments,
ensure a match against an initial comment doesn't cause the
scanner to go back to the beginning of the assembly text.

Fixed: KhronosGroup#5909
  • Loading branch information
dneto0 authored Dec 11, 2024
1 parent 4d2f0b4 commit 1229f1e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/spirv_target_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ bool spvReadEnvironmentFromText(const std::vector<char>& text,
// If no match, determine whether the header has ended (in which case,
// assumption has failed.)
// Skip until the next line.
i = j;
i += j;
for (; i < text.size(); ++i) {
if (text[i] == '\n') break;
}
Expand Down
1 change: 1 addition & 0 deletions test/target_env_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ INSTANTIATE_TEST_SUITE_P(
{" \t ; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1},
// Previous lines
{"; SPIR-V\n; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1},
{"; -\n; SPIR-V\n; Version: 1.1", true, SPV_ENV_UNIVERSAL_1_1},

// After a non-header line
{"OpCapability Shader\n; Version: 1.1", false, kSentinelEnv}}));
Expand Down

0 comments on commit 1229f1e

Please sign in to comment.