From 5257f9dc8476832e230a406c04e5d118088773fc Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Wed, 7 May 2003 16:49:04 +0000 Subject: Fixes crash in #41631 2003-05-07 Rodrigo Moya 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. svn path=/trunk/; revision=21122 --- libical/ChangeLog | 10 ++++++++++ libical/src/libicalvcal/icalvcal.c | 25 ++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libical/ChangeLog b/libical/ChangeLog index 8d9542b7a3..78b9f9a902 100644 --- a/libical/ChangeLog +++ b/libical/ChangeLog @@ -1,3 +1,13 @@ +2003-05-07 Rodrigo Moya + + 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 Part of fix for #34095 diff --git a/libical/src/libicalvcal/icalvcal.c b/libical/src/libicalvcal/icalvcal.c index f070c9cd57..9ab3fa899e 100644 --- a/libical/src/libicalvcal/icalvcal.c +++ b/libical/src/libicalvcal/icalvcal.c @@ -149,10 +149,10 @@ static void convert_floating_time_to_utc (struct icaltimetype *itt) } -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(VObject *object, 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(VObject *object, 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(VObject *object, 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_defaults (VObject *object, 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 -- cgit