This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: cygwin setup 2.510.2.1 does not work because of an invalid iterator.
- From: "Krzysztof Duleba" <krzysan at skrzynka dot pl>
- To: cygwin at cygwin dot com
- Date: Sun, 11 Sep 2005 14:08:48 +0200
- Subject: Re: cygwin setup 2.510.2.1 does not work because of an invalid iterator.
- References: <20050910.112834.57973656.boochang@m4.kcn.ne.jp>
This was originally sent to gmane.os.cygwin.applications, but I can't
write there.
M.Fujii wrote:
>
> Calling erase() in packagemata::ScanDownloadedFiles() invalidates
> iterator i.
> Therefore, ++i after erase() means an operation to a invalid
> iterator. I guess it is the cause of a crash of setup.exe.
>
> - for (set<packageversion>::iterator i = pkg.versions.begin ();
> - i != pkg.versions.end (); ++i)
> + set<packageversion>::iterator i = pkg.versions.begin ();
> + while (i != pkg.versions.end ())
> - pkg.versions.erase(i);
> + pkg.versions.erase(i++);
What's the difference? I mean, you're still using i after erasing it.
Shouldn't it be something along the lines of
{
/* Should we erase */
pkg.versions::iterator next_i = i;
++next_i;
if(next_i == pkg.versions.end()){
pkg.versions.erase(i);
break;
}else{
pkg::value_type tmp = *next_i;
pkg.versions.erase(i);
i = pkg.versions.find(tmp);
}
}else ++i;
Regards
Krzysztof Duleba
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/