[comp.lang.perl] Perl 3 patch 41 fixes to core dumps on HP9000

bernie@chekov.UU.NET (Bernie Macchiusi) (11/21/90)

The fixes below fix core dumps we get on our HP9000/x00.
We are running perl 3 patchlevel 41.

Problem #1:

In doarg.c sub do_subr your not assigning all the fields in csv, 
they all get assigned if the sub is not a usersub and the sub has args. 
But if the it's a usersub and it has args you do a return from do_subr 
without setting savearray and argarray, they will have whatever was malloced 
in Str_new (possibly non zeros). This of course will get you into trouble when 
you try to free savearray and argarray in cmd.c:1197.

The fix (probably an over kill but...)


*** doarg.c.old	Tue Nov 20 14:00:42 1990
--- doarg.c	Tue Nov 20 13:25:25 1990
***************
*** 869,874 ****
--- 869,875 ----
  	}
      }
      str = Str_new(15, sizeof(CSV));
+     (void)bzero((char *)str->str_ptr,sizeof(CSV));
      str->str_state = SS_SCSV;
      (void)apush(savestack,str);
      csv = (CSV*)str->str_ptr;

Problem #2:

In str.c str_sset you are avoiding the case when dstr->str_state == SS_INCR. 
You assign the sstr to dstr without resetting the str->str_ptr. 
This causes core dumps later when you have to do a realloc or a free.

The fix.

*** str.c.old	Tue Nov 20 14:04:22 1990
--- str.c	Tue Nov 20 11:01:12 1990
***************
*** 285,292 ****
  	    sstr->str_pok = 0;			/* wipe out any weird flags */
  	    sstr->str_state = 0;		/* so sstr frees uneventfully */
  	}
! 	else					/* have to copy actual string */
  	    str_nset(dstr,sstr->str_ptr,sstr->str_cur);
  	if (dstr->str_nok = sstr->str_nok)
  	    dstr->str_u.str_nval = sstr->str_u.str_nval;
  	else {
--- 285,298 ----
  	    sstr->str_pok = 0;			/* wipe out any weird flags */
  	    sstr->str_state = 0;		/* so sstr frees uneventfully */
  	}
! 	else {					/* have to copy actual string */
! 	    if (dstr->str_ptr) {
! 		if (dstr->str_state == SS_INCR) {
! 			Str_Grow(dstr,0);
! 		}
! 	    }
  	    str_nset(dstr,sstr->str_ptr,sstr->str_cur);
+ 	}
  	if (dstr->str_nok = sstr->str_nok)
  	    dstr->str_u.str_nval = sstr->str_u.str_nval;
  	else {

--
             .        Bernie Macchiusi
            ..        Product Support Technology Dept - 1930 
 ... ...   ......   
 ........ .......      ESN: 333 2081        
 ...  ...  ...       PHONE: (416) 452 2081            
 ...  ...  ...         FAX: ESN 333 4783  (416) 452-4783        
 ...  ...  ...    INTERNET: bernie@nbrwh8 
 ...  .... ......    COCOS: Bernie.Macchiusi.1930@NT 
 ...   ..   ....            (Bernie Macchiusi :Dept 1930)