[Gnucash-changes] r13415 - gnucash/trunk - Bug#137885: prevent
crash on invalid function formula.
Joshua Sled
jsled at cvs.gnucash.org
Mon Feb 27 20:01:45 EST 2006
Author: jsled
Date: 2006-02-27 20:01:44 -0500 (Mon, 27 Feb 2006)
New Revision: 13415
Trac: http://svn.gnucash.org/trac/changeset/13415
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/app-utils/gnc-exp-parser.c
Log:
Bug#137885: prevent crash on invalid function formula.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-02-27 23:57:16 UTC (rev 13414)
+++ gnucash/trunk/ChangeLog 2006-02-28 01:01:44 UTC (rev 13415)
@@ -1,3 +1,9 @@
+2006-02-27 Joshua Sled <jsled at 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 at employees.org>
* src/engine/gnc-pricedb.[ch]:
Modified: gnucash/trunk/src/app-utils/gnc-exp-parser.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-exp-parser.c 2006-02-27 23:57:16 UTC (rev 13414)
+++ gnucash/trunk/src/app-utils/gnc-exp-parser.c 2006-02-28 01:01:44 UTC (rev 13415)
@@ -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 @@
}
}
+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 @@
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 @@
}
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,
More information about the gnucash-changes
mailing list