mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
d85c866635
commit
9255df9093
@ -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]:
|
||||
|
@ -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;
|
||||
@ -335,7 +344,7 @@ func_op( const char *fname,
|
||||
g_string_printf( realFnName, "gnc:%s", fname );
|
||||
scmFn = gh_eval_str_with_standard_handler( realFnName->str );
|
||||
g_string_free( realFnName, TRUE );
|
||||
if ( ! SCM_PROCEDUREP( scmFn ) ) {
|
||||
if (!SCM_PROCEDUREP(scmFn)) {
|
||||
/* FIXME: handle errors correctly. */
|
||||
printf( "gnc:\"%s\" is not a scm procedure\n", fname );
|
||||
return NULL;
|
||||
@ -362,8 +371,16 @@ 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__),
|
||||
GNC_DENOM_AUTO,
|
||||
|
Loading…
Reference in New Issue
Block a user