This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: [PATCH] pwdgrp::read_group(): Don't call free() twice with the same address
- From: Christopher Faylor <cgf at redhat dot com>
- To: cygwin-patches at cygwin dot com
- Date: Sun, 17 Aug 2003 14:02:51 -0400
- Subject: Re: [PATCH] pwdgrp::read_group(): Don't call free() twice with the same address
- References: <3.0.5.32.20030817105058.007e9b40@mail.attbi.com>
- Reply-to: cygwin-patches at cygwin dot com
On Sun, Aug 17, 2003 at 10:50:58AM -0400, Pierre A. Humblet wrote:
>While Dave Rothenberger has correctly localized the problem
>described in
><http://www.cygwin.com/ml/cygwin/2003-08/msg00364.html>
>the patch
><http://cygwin.com/ml/cygwin-patches/2003-q3/msg00062.html>
>only fixes the symptom of the bug but not the root cause.
>
>Setting gr_mem to &null_ptr below should not be necessary
>because the subsequent load() should reset curr_lines to 0
>and call pwdgrp::parse_group (), which sets gr_mem to &null_ptr.
>Thus free() should never be called twice.
>******
> for (int i = 0; i < gr.curr_lines; i++)
> if ((*group_buf)[i].gr_mem != &null_ptr)
> {
> free ((*group_buf)[i].gr_mem);
> (*group_buf)[i].gr_mem = &null_ptr;
> }
>
> load ("/etc/group");
>******
>
>The original bug report mentions that the problem only occurs
>when /etc is absent. In that case curr_lines is NOT reset by
>pwdgrp::load, although it is incremented when the default entries
>(the ones with "mkpasswd" and "????????") are added to the internal
>group file.
>When /etc does not exist, the default entries are added repeatedly
>and the internal group file keeps growing (ditto for passwd).
>
>I believe that reverting the original patch and applying the one
>below fixes the root bug.
You're absolutely right. Please check in.
cgf