Update of /cvsroot/easycalc/easycalc/mlib
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv27033
Modified Files:
cmatrix.c integ.c matrix.c
Log Message:
Avoid possible memory leaks in using stack_get_val2().
Index: cmatrix.c
===================================================================
RCS file: /cvsroot/easycalc/easycalc/mlib/cmatrix.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** cmatrix.c 22 Sep 2006 17:59:53 -0000 1.26
--- cmatrix.c 27 Sep 2006 13:36:19 -0000 1.27
***************
*** 928,937 ****
{
CError err;
! CMatrix *a,*b,*m,*q;
Int16 i,j;
err = stack_get_val2(stack,&a,&b,cmatrix);
! if (err)
return err;
switch (func->num) {
--- 928,942 ----
{
CError err;
! CMatrix *a = NULL;
! CMatrix *b = NULL;
! CMatrix *m,*q;
Int16 i,j;
err = stack_get_val2(stack,&a,&b,cmatrix);
! if (err) {
! if (a) cmatrix_delete(a);
! if (b) cmatrix_delete(b);
return err;
+ }
switch (func->num) {
***************
*** 1268,1270 ****
cmatrix_delete(m);
return err;
! }
\ No newline at end of file
--- 1273,1275 ----
cmatrix_delete(m);
return err;
! }
Index: integ.c
===================================================================
RCS file: /cvsroot/easycalc/easycalc/mlib/integ.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** integ.c 12 Sep 2006 19:40:56 -0000 1.21
--- integ.c 27 Sep 2006 13:36:19 -0000 1.22
***************
*** 979,983 ****
double error = DEFAULT_ERROR;
double result;
! CodeStack *f1, *f2;
CError err;
CodeStack *argarr = NULL;
--- 979,984 ----
double error = DEFAULT_ERROR;
double result;
! CodeStack *f1 = NULL;
! CodeStack *f2 = NULL;
CError err;
CodeStack *argarr = NULL;
***************
*** 997,1002 ****
return c_badargcount;
! if ((err=stack_get_val2(stack,&f1,&f2,function)))
goto error;
if ((err=stack_get_val2(stack,&min,&max,real))) {
stack_delete(f1);
--- 998,1006 ----
return c_badargcount;
! if ((err=stack_get_val2(stack,&f1,&f2,function))) {
! if (f1) stack_delete(f1);
! if (f2) stack_delete(f2);
goto error;
+ }
if ((err=stack_get_val2(stack,&min,&max,real))) {
stack_delete(f1);
Index: matrix.c
===================================================================
RCS file: /cvsroot/easycalc/easycalc/mlib/matrix.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** matrix.c 22 Sep 2006 17:59:53 -0000 1.30
--- matrix.c 27 Sep 2006 13:36:19 -0000 1.31
***************
*** 1014,1023 ****
{
CError err;
! Matrix *a,*b,*m,*q;
Int16 i,j;
err = stack_get_val2(stack,&a,&b,matrix);
! if (err)
return err;
switch (func->num) {
--- 1014,1028 ----
{
CError err;
! Matrix *a = NULL;
! Matrix *b = NULL;
! Matrix *m,*q;
Int16 i,j;
err = stack_get_val2(stack,&a,&b,matrix);
! if (err) {
! if (a) matrix_delete(a);
! if (b) matrix_delete(b);
return err;
+ }
switch (func->num) {
|