On Sat, Apr 04, 2015 at 10:48:15AM -0300, Gleydson Soares wrote:
> 
> mg(1) segfault.
> it is triggered as follows:
> 
> 1- echo "(start-kbd-macro)" >> $HOME/.mg
> 2- open mg and type twice C-x (
> 
> find below the backtrace and a patch to fix.
> OK?
> 
> Program received signal SIGBUS, Bus error.
> definemacro (f=Variable "f" is not available.
> ) at macro.c:43
> 43                              lp2 = lp1->l_fp;
> (gdb) backtrace
> #0  definemacro (f=Variable "f" is not available.
> ) at macro.c:43
> #1  0x0000038cecf15606 in doin () at kbd.c:158
> #2  0x0000038cecf16d4b in main (argc=Variable "argc" is not available.
> ) at main.c:188
> (gdb)
> 

> ? mg
> ? mg_segfault.diff
> Index: macro.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/macro.c,v
> retrieving revision 1.16
> diff -u -p -r1.16 macro.c
> --- macro.c   19 Mar 2015 21:22:15 -0000      1.16
> +++ macro.c   4 Apr 2015 13:45:15 -0000
> @@ -38,7 +38,7 @@ definemacro(int f, int n)
>       }
>  
>       /* 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);

No, this is obviously not correct. macrodef can't be true here, ever.
Some lines above this we have:
        if (macrodef) {
                ewprintf("already defining macro");
                return (macrodef = FALSE);
        }

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

Reply via email to