gnumeric r16588 - in branches/gnumeric-1-8: . src



Author: mortenw
Date: Tue May 20 01:29:59 2008
New Revision: 16588
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16588&view=rev

Log:
2008-05-19  Morten Welinder  <terra gnome org>

	* src/parser.y (fold_positive_constant, fold_negative_constant,
	build_unary_op, build_binop, build_logical, build_not,
	build_intersect, build_set): Propagate errors.  Fixes #533951.



Modified:
   branches/gnumeric-1-8/ChangeLog
   branches/gnumeric-1-8/NEWS
   branches/gnumeric-1-8/src/parser.y

Modified: branches/gnumeric-1-8/NEWS
==============================================================================
--- branches/gnumeric-1-8/NEWS	(original)
+++ branches/gnumeric-1-8/NEWS	Tue May 20 01:29:59 2008
@@ -35,6 +35,7 @@
 	* Fix R.QPOIS (and related functions) hang.  [#533515]
 	* Fix critical spew.  [#533511]
 	* Fix OPT_BS_DELTA assert.  [#533656]
+	* Fix parser crashes.  [#533951]
 
 --------------------------------------------------------------------------
 Gnumeric 1.8.2

Modified: branches/gnumeric-1-8/src/parser.y
==============================================================================
--- branches/gnumeric-1-8/src/parser.y	(original)
+++ branches/gnumeric-1-8/src/parser.y	Tue May 20 01:29:59 2008
@@ -235,7 +235,7 @@
 static GnmExpr *
 fold_negative_constant (GnmExpr *expr)
 {
-	if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_CONSTANT) {
+	if (expr && GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_CONSTANT) {
 		GnmValue *v = (GnmValue *)expr->constant.value;
 		
 		if (VALUE_IS_FLOAT (v)) {
@@ -253,7 +253,7 @@
 static GnmExpr *
 fold_positive_constant (GnmExpr *expr)
 {
-	if (GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_CONSTANT) {
+	if (expr && GNM_EXPR_GET_OPER (expr) == GNM_EXPR_OP_CONSTANT) {
 		const GnmValue *v = expr->constant.value;
 		if (VALUE_IS_FLOAT (v))
 			return expr;
@@ -265,6 +265,8 @@
 static GnmExpr *
 build_unary_op (GnmExprOp op, GnmExpr *expr)
 {
+	if (!expr) return NULL;
+
 	unregister_allocation (expr);
 	return register_expr_allocation (gnm_expr_new_unary (op, expr));
 }
@@ -272,6 +274,8 @@
 static GnmExpr *
 build_binop (GnmExpr *l, GnmExprOp op, GnmExpr *r)
 {
+	if (!l || !r) return NULL;
+
 	unregister_allocation (r);
 	unregister_allocation (l);
 	return register_expr_allocation (gnm_expr_new_binary (l, op, r));
@@ -282,6 +286,8 @@
 {
 	static GnmFunc *and_func = NULL, *or_func = NULL;
 
+	if (!l || !r) return NULL;
+
 	if (and_func == NULL)
 		and_func = gnm_func_lookup ("AND", NULL);
 	if (or_func == NULL)
@@ -297,6 +303,9 @@
 build_not (GnmExpr *expr)
 {
 	static GnmFunc *not_func = NULL;
+
+	if (!expr) return NULL;
+
 	if (not_func == NULL)
 		not_func = gnm_func_lookup ("NOT", NULL);
 	unregister_allocation (expr);
@@ -375,6 +384,8 @@
 static GnmExpr *
 build_intersect (GnmExpr *l, GnmExpr *r)
 {
+	if (!l || !r) return NULL;
+
 	if (gnm_expr_is_rangeref (l) && gnm_expr_is_rangeref (r))
 		return build_binop (l, GNM_EXPR_OP_INTERSECT, r);
 	report_err (state, g_error_new (1, PERR_SET_CONTENT_MUST_BE_RANGE,
@@ -390,7 +401,7 @@
 	GnmExprList *ptr;
 	for (ptr = list; ptr != NULL ; ptr = ptr->next) {
 		GnmExpr const *expr = ptr->data;
-		if (!gnm_expr_is_rangeref (expr)) {
+		if (!expr || !gnm_expr_is_rangeref (expr)) {
 			report_err (state, g_error_new (1, PERR_SET_CONTENT_MUST_BE_RANGE,
 				_("All entries in the set must be references")),
 				state->ptr, 0);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]