This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, libstdc++/63497] Avoid dereferencing invalid iterator in regex_executor


On Tue, Oct 21, 2014 at 3:25 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
> Did you manage to produce a testcase that crashed on trunk?

Oh I forgot to mention that I've tried my best to make a testcase that
crash the trunk, but failed :).

I'm not sure if I should directly put an assert in the code and make a
testcase to explode it. Now I think it's better to do it.

> Is it really necessary to modify _M_current here?
> Couldn't you do:
>
>       auto __pre = _M_current;
>       if (_M_is_word(*--__pre))
>         __left_is_word = true;
>
> Then the function could remain const, couldn't it?

That's exactly what I did in the early version of this patch. But
later I changed because I assume that copying an iterator is
potentially expensive, but mutating is cheaper.

Making this function const may bring some optimization, doesn't it?
But I have no idea how much it will bring and if it's worthy.


-- 
Regards,
Tim Shen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]