Re: [Cleanup?] File (struct stat handling)

From: nobu.nokada@...
Date: 2002-08-23 14:52:40 UTC
List: ruby-core #356
Hi,

At Fri, 23 Aug 2002 21:56:02 +0900,
Michal Rokos wrote:
> @@ -2024,12 +2028,11 @@ rb_stat_clone(obj)
>  
>      clone = rb_obj_alloc(RBASIC(obj)->klass);
>      CLONESETUP(clone,obj);
> +    
>      if (DATA_PTR(obj)) {
>  	nst = ALLOC(struct stat);
> -	*nst = *(struct stat*)DATA_PTR(obj);
> -	DATA_PTR(clone) = nst;
> +	memcpy(DATA_PTR(clone), DATA_PTR(obj), sizeof(struct stat));
>      }
> -
>      return clone;
>  }

Since File::Stat.allocate doesn't initialize DATA_PTR, this
change causes SEGV, and also memory leak.

> PS: Don't worry - no more patches are comming (It's weekend and
> BankHoliday monday) :-)

Don't mind, here is ruby-cleanup ML :-).

-- 
Nobu Nakada

In This Thread