Re: Bug in Safe.e discovered today

new topic     » goto parent     » topic index » view thread      » older message » newer message

Al Getz wrote:
> I've managed to uncover a bug in Safe.e today while working on
> a program that used to allocate a struct incorrectly.
> 
> 
> The problem occurs in the routine:
> 
> global function allocate_string(sequence s)
> -- create a C-style null-terminated string in memory
>     atom mem
>     
>     mem = allocate(length(s) + 1)
>     if mem then
>       poke(mem, s)
>       poke(mem+length(s), 0)  -- Thanks to Aku
>     end if
>     return mem
> end function
> 
> If the sequence s is null (s="") it causes a machine error to be generated
> while trying to poke into memory.
> 
> The temporary workaround was this:
> 
> global function allocate_string(sequence s)
> -- create a C-style null-terminated string in memory
>     atom mem
>     
>     mem = allocate(length(s) + 1)
>     if mem and length(s)>0 then
>       poke(mem, s)
>       poke(mem+length(s), 0)  -- Thanks to Aku
>     end if
>     return mem
> end function
> 
> 
> On the plus side, because there was a level of protection written
> for 'c_func' too, after the above was implemented safe.e caught my
> Win API call with the badly allocated struct.  Very nice!
> 
> Thanks again to Matt for suggesting the use of Safe.e .

That bug was fixed more than a year ago in 2.5 alpha.
Maybe it's time to upgrade?

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu