gnumeric r16587 - in trunk: . src



Author: mortenw
Date: Tue May 20 01:29:41 2008
New Revision: 16587
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16587&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:
   trunk/ChangeLog
   trunk/NEWS
   trunk/src/parser.y

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Tue May 20 01:29:41 2008
@@ -18,6 +18,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.9.0

Modified: trunk/src/parser.y
==============================================================================
--- trunk/src/parser.y	(original)
+++ trunk/src/parser.y	Tue May 20 01:29:41 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]