Skip to content

Commit 14ba7af

Browse files
committed
simplifier: Assert that vertex_lock[] only contains 0/1 values
As part of forward compatibility strategy, vertex_lock[] may become a bitset or enum in the future (for example, it may be valuable to specify artificial external seams, or complex wedges, via this mechanism). To avoid a situation where existing code computes values that aren't 0/1 and behavior silently changes with future updates, we assert the range of the locks before applying them.
1 parent f270f4d commit 14ba7af

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/simplifier.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,13 @@ static void classifyVertices(unsigned char* result, unsigned int* loop, unsigned
437437
{
438438
// vertex_lock may lock any wedge, not just the primary vertex, so we need to lock the primary vertex and relock any wedges
439439
for (size_t i = 0; i < vertex_count; ++i)
440-
if (vertex_lock[sparse_remap ? sparse_remap[i] : i])
440+
{
441+
unsigned int ri = sparse_remap ? sparse_remap[i] : unsigned(i);
442+
assert(vertex_lock[ri] <= 1); // values other than 0/1 are reserved for future use
443+
444+
if (vertex_lock[ri])
441445
result[remap[i]] = Kind_Locked;
446+
}
442447

443448
for (size_t i = 0; i < vertex_count; ++i)
444449
if (result[remap[i]] == Kind_Locked)

0 commit comments

Comments
 (0)