[Fractdev] save_stack() called without calling restore_stack…

Top Page
Delete this message
Reply to this message
Author: Richard
Date:  
To: fractdev
Subject: [Fractdev] save_stack() called without calling restore_stack()
This looks like a bug to me.

fractalb.c, ComplexPower_bf:

_BFCMPLX *ComplexPower_bf(_BFCMPLX *t, _BFCMPLX *xx, _BFCMPLX *yy)
{
_BFCMPLX tmp;
bf_t e2x, siny, cosy;
int saved; saved = save_stack();
e2x = alloc_stack(rbflength+2);
siny = alloc_stack(rbflength+2);
cosy = alloc_stack(rbflength+2);
tmp.x = alloc_stack(rbflength+2);
tmp.y = alloc_stack(rbflength+2);

/* 0 raised to anything is 0 */
if (is_bf_zero(xx->x) && is_bf_zero(xx->y))
{
clear_bf(t->x);
clear_bf(t->y);
return(t);
}

cmplxlog_bf(t, xx);
cplxmul_bf(&tmp, t, yy);
exp_bf(e2x,tmp.x);
sincos_bf(siny,cosy,tmp.y);
mult_bf(t->x, e2x, cosy);
mult_bf(t->y, e2x, siny);
restore_stack(saved);
return(t);
}

When the 'if' is taken above, restore_stack() is not called and
bignum memory stack is leaked.

This structure is repeated again in ComplexPower_bn.
-- 
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
      <http://www.xmission.com/~legalize/book/download/index.html>


Legalize Adulthood! <http://blogs.xmission.com/legalize/>