variable.c is still fighting back :-)


To "Ng-Spice-Devel (E-mail)" <ng-spice-devel@ieee.ing.uniroma1.it>
From "Gillespie, Alan" <Alan.Gillespie@analog.com>
Date Fri, 9 Feb 2001 10:02:25 -0000
Delivered-To mailing list ng-spice-devel@ieee.ing.uniroma1.it
Mailing-List contact ng-spice-devel-help@ieee.ing.uniroma1.it; run by ezmlm
Reply-To ng-spice-devel@ieee.ing.uniroma1.it


Hi Folks,

I compiled and ran 14-pre1 last night, and got a seg fault
straight away. I notice that other people seem to be having
similar trouble. I traced it back to good old variable.c :-)

It appears that Paolo did exactly what I did the first time
I applied Glao's last fix. It needs to be applied in two
places, not just one.

The culprit is ft_numparse, which appears twice in the file.
The first appearance (line 311) has been fixed like so :-

       copyval = ss = cp_unquote(wl->wl_word);
       td = ft_numparse(&ss, FALSE);
       if (td) {
           vv->va_type = VT_REAL;
           vv->va_real = *td;
       } else {
           vv->va_type = VT_STRING;
           vv->va_string = copy(ss);
       }
       tfree(copyval);/*DG: must free ss any way to avoid cp_unquote
memory leak*/

But the second one (line 344) needs the same fix. Currently
it's :-

        ss = cp_unquote(val);
        td = ft_numparse(&ss, FALSE);
        vv = alloc(struct variable);
        vv->va_name = copy(name);
        vv->va_next = vars;
        vars = vv;
        if (td) {
            /*** We should try to get VT_NUM's... */
            vv->va_type = VT_REAL;
            vv->va_real = *td;
        } else {
            vv->va_type = VT_STRING;
            vv->va_string = copy(val);
        }
        tfree(ss);/*DG: avoid cp_unquote memory leak */

It needs to be :-

        copyval = ss = cp_unquote(val);
        td = ft_numparse(&ss, FALSE);
        vv = alloc(struct variable);
        vv->va_name = copy(name);
        vv->va_next = vars;
        vars = vv;
        if (td) {
            /*** We should try to get VT_NUM's... */
            vv->va_type = VT_REAL;
            vv->va_real = *td;
        } else {
            vv->va_type = VT_STRING;
            vv->va_string = copy(val);
        }
       tfree(copyval);/*DG: must free ss any way to avoid cp_unquote
memory leak*/

That is, lines 343 and 357 need to change. Or something like
that. I'd say this pre-release thing is quite a good idea,
'cos we can clear out the glaring errors before we embarrass
ourselves ;-)

Cheers,

Alan

Partial thread listing: