Skip to content

Potential missing modelviewMatrixStack.pop() in Bin::traverse #1719

@simwangrui

Description

@simwangrui

Hi ,
Thank you for your continuous work on VSG. I was reviewing the latest main branch and noticed a potential issue in the Bin::traverse(RecordTraversal& rt) const function within bin.cpp.
In the traversal loop, when the matrix index changes, a new matrix is pushed onto the stack:

if (element.matrixIndex != previousMatrixIndex) { state->modelviewMatrixStack.push(_matrices[element.matrixIndex]); // ... }
However, it appears there is no corresponding state->modelviewMatrixStack.pop() after the child node (element.child->accept(rt)) finishes traversing. This could lead to an unbalanced matrix stack during deep traversal.
I believe adding a pop() operation after the child traversal (similar to how stateCommands are handled) might resolve this.
Could you kindly take a look when you have a moment? I might have misunderstood the design, so I'd appreciate your insights.
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions