Re: SIGSEGV in dc, at bcode.c:277 (function reset_bmachine())

From: Rui Paulo <rpaulo_at_gmail.com>
Date: Tue, 13 Apr 2010 10:24:00 +0100
On 13 Apr 2010, at 08:48, Hizel Ildar wrote:
> My patch:
> 
> foo# diff -ruN dc.c.orig dc.c
> --- dc.c.orig   2010-04-13 10:33:22.000000000 +0400
> +++ dc.c        2010-04-13 11:44:18.000000000 +0400
> _at__at_ -87,12 +87,16 _at__at_
>        while ((ch = getopt_long(argc, argv, "e:f:Vx", long_options, NULL)) != -1) {
>                switch (ch) {
>                case 'e':
> +                       if(!preproc_done)
> +                              init_bmachine(extended_regs);
>                        src_setstring(&src, optarg);
>                        reset_bmachine(&src);
>                        eval();
>                        preproc_done = true;
>                        break;
>                case 'f':
> +                       if(!preproc_done)
> +                              init_bmachine(extended_regs);
>                        procfile(optarg);
>                        preproc_done = true;
>                        break;
> _at__at_ -114,7 +118,9 _at__at_
>        argc -= optind;
>        argv += optind;
> 
> -       init_bmachine(extended_regs);
> +        if (!preproc_done)
> +               init_bmachine(extended_regs);
> +
>        setlinebuf(stdout);
>        setlinebuf(stderr);
> 
> 
> test:
> 
> foo# dc -f /tmp/test
> 3
> foo# dc -e "6 2/p"
> 3
> foo# dc -e "6 2/p" -f /tmp/test
> 3
> 3
> foo# dc -e "6 2/p" -f /tmp/test /tmp/test
> 3
> 3
> 3

This looks sane to me.

Regards,
--
Rui Paulo
Received on Tue Apr 13 2010 - 07:24:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:02 UTC