delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/11/08:11:23

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
From: "Krzysztof Duleba" <krzysan AT skrzynka DOT pl>
Subject: Re: cygwin setup 2.510.2.1 does not work because of an invalid iterator.
Date: Sun, 11 Sep 2005 14:08:48 +0200
Lines: 39
Message-ID: <dg16o0$n7d$1@sea.gmane.org>
References: <20050910 DOT 112834 DOT 57973656 DOT boochang AT m4 DOT kcn DOT ne DOT jp>
Mime-Version: 1.0
X-IsSubscribed: yes

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019