Bug#137885: prevent crash on invalid function formula.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13415 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled 2006-02-28 01:01:44 +00:00
parent d85c866635
commit 9255df9093
2 changed files with 28 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2006-02-27 Joshua Sled <jsled@asynchronous.org>
* src/app-utils/gnc-exp-parser.c (func_op): No longer crashes on
an invalid formula, though it's also not very clear what's going
on. Basically fixes Bug#137885.
2006-02-27 David Hampton <hampton@employees.org>
* src/engine/gnc-pricedb.[ch]:

View File

@ -27,6 +27,7 @@
#include <locale.h>
#include <string.h>
#include "gfec.h"
#include "finproto.h"
#include "fin_spl_protos.h"
#include "gnc-filepath-utils.h"
@ -37,6 +38,8 @@
#define GROUP_NAME "Variables"
static QofLogModule log_module = GNC_MOD_GUI;
/** Data Types *****************************************************/
typedef struct ParserNum
@ -319,10 +322,16 @@ update_variables (var_store_ptr vars)
}
}
static char* _function_evaluation_error_msg = NULL;
static void
_exception_handler(const char *error_message)
{
_function_evaluation_error_msg = (char*)error_message;
}
static
void*
func_op( const char *fname,
int argc, void **argv )
func_op(const char *fname, int argc, void **argv)
{
SCM scmFn, scmArgs, scmTmp;
int i;
@ -362,7 +371,15 @@ func_op( const char *fname,
}
scmArgs = scm_cons( scmTmp, scmArgs );
}
scmTmp = scm_apply( scmFn, scmArgs , SCM_EOL);
//scmTmp = scm_apply(scmFn, scmArgs , SCM_EOL);
scmTmp = gfec_apply(scmFn, scmArgs, _exception_handler);
if (_function_evaluation_error_msg != NULL)
{
PERR("function eval error: [%s]\n", _function_evaluation_error_msg);
_function_evaluation_error_msg = NULL;
return NULL;
}
result = g_new0( gnc_numeric, 1 );
*result = double_to_gnc_numeric( scm_num2dbl(scmTmp, __FUNCTION__),