Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] c-exp.y, memory leak
@ 2007-08-05  1:51 msnyder
  2007-08-05 18:52 ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: msnyder @ 2007-08-05  1:51 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 171.txt --]
[-- Type: text/plain, Size: 852 bytes --]

2007-08-04  Michael Snyder  <msnyder@access-company.com>

	* c-exp.y (parse_number): Memory leak.

Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.38
diff -p -r1.38 c-exp.y
*** c-exp.y	12 Jun 2007 15:33:03 -0000	1.38
--- c-exp.y	5 Aug 2007 01:49:51 -0000
*************** parse_number (p, len, parsed_float, puti
*** 1096,1104 ****
  	    putithere->typed_val_float.type = 
  	      builtin_type (current_gdbarch)->builtin_long_double;
  	  else
! 	    return ERROR;
  	}
  
        return FLOAT;
      }
  
--- 1096,1108 ----
  	    putithere->typed_val_float.type = 
  	      builtin_type (current_gdbarch)->builtin_long_double;
  	  else
! 	    {
! 	      free (s);
! 	      return ERROR;
! 	    }
  	}
  
+       free (s);
        return FLOAT;
      }
  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] c-exp.y, memory leak
  2007-08-05  1:51 [PATCH] c-exp.y, memory leak msnyder
@ 2007-08-05 18:52 ` Mark Kettenis
  2007-08-05 22:08   ` Michael Snyder
  2007-08-10 22:29   ` msnyder
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Kettenis @ 2007-08-05 18:52 UTC (permalink / raw)
  To: msnyder; +Cc: gdb-patches

> Date: Sat, 4 Aug 2007 18:51:09 -0700 (PDT)
> From: msnyder@sonic.net
> 
> 2007-08-04  Michael Snyder  <msnyder@access-company.com>
> 
> 	* c-exp.y (parse_number): Memory leak.

Shouldn't this use xfree()?

> Index: c-exp.y
> ===================================================================
> RCS file: /cvs/src/src/gdb/c-exp.y,v
> retrieving revision 1.38
> diff -p -r1.38 c-exp.y
> *** c-exp.y	12 Jun 2007 15:33:03 -0000	1.38
> --- c-exp.y	5 Aug 2007 01:49:51 -0000
> *************** parse_number (p, len, parsed_float, puti
> *** 1096,1104 ****
>   	    putithere->typed_val_float.type = 
>   	      builtin_type (current_gdbarch)->builtin_long_double;
>   	  else
> ! 	    return ERROR;
>   	}
>   
>         return FLOAT;
>       }
>   
> --- 1096,1108 ----
>   	    putithere->typed_val_float.type = 
>   	      builtin_type (current_gdbarch)->builtin_long_double;
>   	  else
> ! 	    {
> ! 	      free (s);
> ! 	      return ERROR;
> ! 	    }
>   	}
>   
> +       free (s);
>         return FLOAT;
>       }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] c-exp.y, memory leak
  2007-08-05 18:52 ` Mark Kettenis
@ 2007-08-05 22:08   ` Michael Snyder
  2007-08-10 22:29   ` msnyder
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Snyder @ 2007-08-05 22:08 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches





> > Date: Sat, 4 Aug 2007 18:51:09 -0700 (PDT)
> > From: msnyder@sonic.net
> >
> > 2007-08-04  Michael Snyder  <msnyder@access-company.com>
> >
> > * c-exp.y (parse_number): Memory leak.
>
> Shouldn't this use xfree()?

Ah, right, that's what I meant to say.   ;-)

>
> > Index: c-exp.y
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/c-exp.y,v
> > retrieving revision 1.38
> > diff -p -r1.38 c-exp.y
> > *** c-exp.y 12 Jun 2007 15:33:03 -0000 1.38
> > --- c-exp.y 5 Aug 2007 01:49:51 -0000
> > *************** parse_number (p, len, parsed_float, puti
> > *** 1096,1104 ****
> >       putithere->typed_val_float.type =
> >         builtin_type (current_gdbarch)->builtin_long_double;
> >     else
> > !     return ERROR;
> >   }
> >
> >         return FLOAT;
> >       }
> >
> > --- 1096,1108 ----
> >       putithere->typed_val_float.type =
> >         builtin_type (current_gdbarch)->builtin_long_double;
> >     else
> > !     {
> > !       free (s);
> > !       return ERROR;
> > !     }
> >   }
> >
> > +       free (s);
> >         return FLOAT;
> >       }
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] c-exp.y, memory leak
  2007-08-05 18:52 ` Mark Kettenis
  2007-08-05 22:08   ` Michael Snyder
@ 2007-08-10 22:29   ` msnyder
  2007-08-17 23:28     ` msnyder
  1 sibling, 1 reply; 5+ messages in thread
From: msnyder @ 2007-08-10 22:29 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: msnyder, gdb-patches

>> Date: Sat, 4 Aug 2007 18:51:09 -0700 (PDT)
>> From: msnyder@sonic.net
>>
>> 2007-08-04  Michael Snyder  <msnyder@access-company.com>
>>
>> 	* c-exp.y (parse_number): Memory leak.
>
> Shouldn't this use xfree()?

Actually, although arguably they should -- I'm not so sure.

It's kind of a mess -- c-exp.y uses malloc, and then Makefile.in
runs sed on c-exp.c to transform malloc to xmalloc.  No such sed
transform is done to convert free to xfree, and there is at least
one other call to free in there that does not get converted.

I'm reluctant to mess with the sed scripts.  "free" is just too
common a string.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] c-exp.y, memory leak
  2007-08-10 22:29   ` msnyder
@ 2007-08-17 23:28     ` msnyder
  0 siblings, 0 replies; 5+ messages in thread
From: msnyder @ 2007-08-17 23:28 UTC (permalink / raw)
  To: msnyder; +Cc: Mark Kettenis, msnyder, gdb-patches

>>> Date: Sat, 4 Aug 2007 18:51:09 -0700 (PDT)
>>> From: msnyder@sonic.net
>>>
>>> 2007-08-04  Michael Snyder  <msnyder@access-company.com>
>>>
>>> 	* c-exp.y (parse_number): Memory leak.
>>
>> Shouldn't this use xfree()?
>
> Actually, although arguably they should -- I'm not so sure.
>
> It's kind of a mess -- c-exp.y uses malloc, and then Makefile.in
> runs sed on c-exp.c to transform malloc to xmalloc.  No such sed
> transform is done to convert free to xfree, and there is at least
> one other call to free in there that does not get converted.
>
> I'm reluctant to mess with the sed scripts.  "free" is just too
> common a string.

Alright -- I'm going to commit this using "free" rather than
"xfree", on the premise that the file already calls free once,
and doesn't call xfree at all.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-17 23:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-05  1:51 [PATCH] c-exp.y, memory leak msnyder
2007-08-05 18:52 ` Mark Kettenis
2007-08-05 22:08   ` Michael Snyder
2007-08-10 22:29   ` msnyder
2007-08-17 23:28     ` msnyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox