On Sat, Apr 04, 2015 at 03:23:45PM -0300, Gleydson Soares wrote:
> >                 return (macrodef = FALSE);
> 
> but we shouldn't change macrodef here.
> 

I hate the startup file.
Look, this is a use after free, but I can't find it...

#0  0x00001b9de0b1b77f in definemacro (f=0, n=1)
    at /usr/src/usr.bin/mg/macro.c:43
43                              lp2 = lp1->l_fp;
(gdb) p *maclhead
$1 = {l_fp = 0xdfdfdfdfdfdfdfdf, l_bp = 0xdfdfdfdfdfdfdfdf, 
  l_size = -538976289, l_used = -538976289, 
  l_text = 0xdfdfdfdfdfdfdfdf <Address 0xdfdfdfdfdfdfdfdf out of bounds>}

also: what Steven McDonald says

> ? mg
> ? mg_segfault.diff
> ? v2_mg_segfault.diff
> Index: macro.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/macro.c,v
> retrieving revision 1.16
> diff -u -p -u -p -r1.16 macro.c
> --- macro.c   19 Mar 2015 21:22:15 -0000      1.16
> +++ macro.c   4 Apr 2015 16:09:38 -0000
> @@ -34,11 +34,11 @@ definemacro(int f, int n)
>  
>       if (macrodef) {
>               ewprintf("already defining macro");
> -             return (macrodef = FALSE);
> +             return (FALSE);
>       }
>  
>       /* free lines allocated for string arguments */
> -     if (maclhead != NULL) {
> +     if (macrodef && maclhead != NULL) {
>               for (lp1 = maclhead->l_fp; lp1 != maclhead; lp1 = lp2) {
>                       lp2 = lp1->l_fp;
>                       free(lp1);


-- 
I'm not entirely sure you are real.

Reply via email to