Menu

#107 Helper function BulkyFiveNakade() is passing a temporary SgPointSet object to iterator

2.0
closed
nobody
None
Fixed
2019-01-19
2019-01-19
No

After I discovered the issue described in ticket #106, I had a look through the entire Fuego code base to find other similar cases where a temporary object is passed to an iterator constructor. I searched for lines containing the word "Iterator", naively assuming that the pattern would most likely be repeated when one of the various project-specific iterator classes was used. These iterator classes all seem to contain the word "Iterator" in the class name.

I found only one other case, which does not mean that none other exists.

The problematic code is in the helper function BulkyFiveNakade() in GoEyeUtil.cpp:

[...]
SG_ASSERT((points & bd.AllEmpty()).IsSize(2));
for (SgSetIterator it(points & bd.AllEmpty()); it; ++it)
[...]

I don't have runtime repro steps that prove that the above code is faulty, but if the premise in ticket #106 is accepted as valid it is evident that the code should be changed so that it passes a non-temporary object to the SgSetIterator constructor.

I propose to change the code to this:

[...]
SgPointSet empty = (points & bd.AllEmpty());
SG_ASSERT(empty.IsSize(2));
for (SgSetIterator it(empty); it; ++it)
[...]

The attached patch produces the code above. It was created with svn diff go/GoEyeUtil.cpp.

1 Attachments

Discussion

  • Patrick Näf

    Patrick Näf - 2019-01-19
    • Milestone: later --> Fuego 2.0
     
  • Martin Müller

    Martin Müller - 2019-01-19
    • status: new --> closed
    • Milestone: Fuego 2.0 --> 2.0
    • Resolution: --> Fixed
     

Log in to post a comment.

MongoDB Logo MongoDB