Opened 10 years ago

Closed 5 years ago

#7048 closed Bugs (invalid)

Iterator's value is not checked properly in range_run class.

Reported by: g.gupta@… Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.50.0 Severity: Problem
Keywords: Cc: yogen.saini@…

Description

In File boost/spirit/home/classic/utility/impl/chset/range_run.ipp



if (iter != run.end() && iter->includes(v))
                    return true;
                if (iter != run.begin())
                    return (--iter)->includes(v);
            }
            return false;


Here iter = run.end() condition is not checked.
So, attached patch is the fix for it.

Attachments (1)

range_run.ipp_patch (728 bytes ) - added by g.gupta@… 10 years ago.
Patch file for the reported Bug.

Download all attachments as: .zip

Change History (4)

by g.gupta@…, 10 years ago

Attachment: range_run.ipp_patch added

Patch file for the reported Bug.

comment:1 by Joel de Guzman, 10 years ago

Do you have a minimal test case exhibiting this edge case problem? I'll need one. I think the logic is just fine as it is. If iter is at the end, it gets decremented before dereferencing it (but only if it's not at begin already).

comment:2 by Nikita Kniazev <nok.raven@…>, 5 years ago

There is no problem to decrement an end iterator, C++ Standard allows it. So it is preferably valid code and I see no reason to check add a check for end iter != run.end() before decrementing --iter.

comment:3 by Joel de Guzman, 5 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.