This is the mail archive of the
mailing list for the libstdc++ project.
Re: [Patch, libstdc++/63497] Avoid dereferencing invalid iterator in regex_executor
- From: Tim Shen <timshen at google dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 21 Oct 2014 09:45:24 -0700
- Subject: Re: [Patch, libstdc++/63497] Avoid dereferencing invalid iterator in regex_executor
- Authentication-results: sourceware.org; auth=none
- References: <CAG4ZjNm4bW1BYdjUy-f1ydw66c-j7W2oa=SWRsc7c2P2rD4Tqg at mail dot gmail dot com> <20141021102545 dot GI3033 at redhat dot com>
On Tue, Oct 21, 2014 at 3:25 AM, Jonathan Wakely <firstname.lastname@example.org> 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.