diff --git a/ChangeLog b/ChangeLog
index 3313427..1554642 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-24  Albert Graef  <Dr.Graef@t-online.de>
+
+	* src/sheet-object-widget.c (dep_hash, dep_equal, dep_destroy)
+	(set_group): Check that texprs are non-NULL before hashing,
+	comparing, referencing or unreferencing them.
+
 2009-09-20  Morten Welinder  <terra@gnome.org>
 
 	* configure.in: Post-release bump.
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 84c57cd..ea72551 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -2339,7 +2339,7 @@ static guint
 dep_hash(GnmDependent const *k)
 {
 	if (k)
-		return (GPOINTER_TO_INT(k->sheet) << 16) + gnm_expr_top_hash(k->texpr);
+		return (GPOINTER_TO_INT(k->sheet) << 16) + (k->texpr?gnm_expr_top_hash(k->texpr):0);
 	else
 		return 0;
 }
@@ -2348,7 +2348,12 @@ static gint
 dep_equal(GnmDependent const *k1, GnmDependent const *k2)
 {
 	if (k1 && k2)
-		return k1->sheet == k2->sheet && gnm_expr_top_equal(k1->texpr, k2->texpr);
+		if (k1->sheet != k2->sheet)
+			return 0;
+		else if (k1->texpr && k2->texpr)
+			return gnm_expr_top_equal(k1->texpr, k2->texpr);
+		else
+			return k1->texpr == k2->texpr;
 	else
 		return k1==k2;
 }
@@ -2357,7 +2362,7 @@ static void
 dep_destroy(GnmDependent *k)
 {
 	if (k) {
-		gnm_expr_top_unref(k->texpr);
+		if (k->texpr) gnm_expr_top_unref(k->texpr);
 		g_free(k);
 	}
 }
@@ -2380,7 +2385,7 @@ static void set_group(const GnmDependent *d, GSList *g)
 		if (d) {
 			dep = g_new(GnmDependent, 1);
 			*dep = *d;
-			gnm_expr_top_ref(dep->texpr);
+			if (dep->texpr) gnm_expr_top_ref(dep->texpr);
 		} else
 			dep = NULL;
 		g_hash_table_insert (groups, dep, g);
