Re: [evolution-patches] patch for crash in #41631



On Wed, 2003-05-07 at 15:01, JP Rosevear wrote:
> On Wed, 2003-05-07 at 07:18, Rodrigo Moya wrote:
> > This fixes the crash in that bug, although it doesn't seem the best fix.
> > It should probably notify somewhat that there was an invalid property.
> > 
> > Any thoughts? or can I commit this?
> 
> Maybe icalvcal_traverse_objects should return an int indicating
> success/failure so icalvcal_convert* can return NULL if there is a
> problem.
> 
here's a patch that implements that.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libical/ChangeLog,v
retrieving revision 1.138
diff -u -p -r1.138 ChangeLog
--- ChangeLog	18 Mar 2003 01:48:40 -0000	1.138
+++ ChangeLog	7 May 2003 16:10:51 -0000
@@ -1,3 +1,13 @@
+2003-05-07  Rodrigo Moya <rodrigo ximian com>
+
+	Fixes crash in #41631
+
+	* src/libicalvcal/icalvcal.c (icalvcal_traverse_objects): changed to
+	return an error code and to return immediately if one of the recurrent
+	calls return an error.
+	(icalvcal_convert_with_defaults): if icalvcal_traverse_objects return
+	an error, return NULL.
+
 2003-03-17  Hans Petter Jansson  <hpj ximian com>
 
 	Part of fix for #34095
Index: src/libicalvcal/icalvcal.c
===================================================================
RCS file: /cvs/gnome/libical/src/libicalvcal/icalvcal.c,v
retrieving revision 1.2
diff -u -p -r1.2 icalvcal.c
--- src/libicalvcal/icalvcal.c	6 Feb 2002 23:16:12 -0000	1.2
+++ src/libicalvcal/icalvcal.c	7 May 2003 16:10:52 -0000
@@ -149,10 +149,10 @@ static void convert_floating_time_to_utc
 }
 
 
-static void icalvcal_traverse_objects(VObject *object,
-				      icalcomponent* last_comp,
-				      icalproperty* last_prop,
-				      icalvcal_defaults *defaults)
+static int icalvcal_traverse_objects(VObject *object,
+				     icalcomponent* last_comp,
+				     icalproperty* last_prop,
+				     icalvcal_defaults *defaults)
 {
     VObjectIterator iterator;
     char* name = "[No Name]";
@@ -161,8 +161,7 @@ static void icalvcal_traverse_objects(VO
     
     if ( vObjectName(object)== 0){
 	printf("ERROR, object has no name");
-	assert(0);
-	return;
+	return 0;
     }
 
     name = (char*)vObjectName(object);
@@ -185,8 +184,7 @@ static void icalvcal_traverse_objects(VO
 	   icalproperty_set_x_name(prop,name);
 	   icalcomponent_add_property(last_comp,prop);
 	} else {
-	    assert(0);
-	    return;
+	    return 0;
 	}
 
     } else {
@@ -276,12 +274,16 @@ static void icalvcal_traverse_objects(VO
            should use it as the 'last_comp' */
 
 	if(subc!=0){
-	    icalvcal_traverse_objects(eachProp,subc,last_prop,defaults);
+	    if (!icalvcal_traverse_objects(eachProp,subc,last_prop,defaults))
+	        return 0;
 	
 	} else {
-	    icalvcal_traverse_objects(eachProp,last_comp,last_prop,defaults);
+	    if (!icalvcal_traverse_objects(eachProp,last_comp,last_prop,defaults))
+		return 0;
 	}
     }
+
+    return 1;
 }
 
 icalcomponent* icalvcal_convert_with_defaults (VObject *object,
@@ -307,7 +309,8 @@ icalcomponent* icalvcal_convert_with_def
    printf ("===========================================\n");
 #endif
 
-   icalvcal_traverse_objects(object,container,0,defaults);
+   if (!icalvcal_traverse_objects(object,container,0,defaults))
+	   return 0;
    
    /* HACK. I am using the extra 'container' component because I am
       lazy. I know there is a way to get rid of it, but I did not care


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