[Freeassociation-devel] Not freeing memory on errors
Alvaro Manera
alvaro.manera at nokia.com
Mon Jun 8 00:12:31 PDT 2009
Hi once more.
This is a combined patch. Fixing not freeing when there is an error allocating
memory. Let me know what you think....
Index: src/libical/icalvalue.c
===================================================================
--- src/libical/icalvalue.c (revision 930)
+++ src/libical/icalvalue.c (working copy)
@@ -136,6 +136,7 @@
new->data.v_string=icalmemory_strdup(old->data.v_string);
if ( new->data.v_string == 0 ) {
+ icalvalue_free(new);
return 0;
}
@@ -148,6 +149,7 @@
new->data.v_recur = malloc(sizeof(struct icalrecurrencetype));
if(new->data.v_recur == 0){
+ icalvalue_free(new);
return 0;
}
@@ -163,6 +165,7 @@
new->x_value=icalmemory_strdup(old->x_value);
if (new->x_value == 0) {
+ icalvalue_free(new);
return 0;
}
}
Index: src/libical/icalproperty.c
===================================================================
--- src/libical/icalproperty.c (revision 930)
+++ src/libical/icalproperty.c (working copy)
@@ -196,6 +196,7 @@
if(comp == 0){
icalerror_set_errno(ICAL_PARSE_ERROR);
+ free(buf);
return 0;
}
Index: src/libicalvcal/icalvcal.c
===================================================================
--- src/libicalvcal/icalvcal.c (revision 930)
+++ src/libicalvcal/icalvcal.c (working copy)
@@ -175,6 +175,7 @@
/* The root object must be a VCALENDAR */
if(*name==0 || strcmp(name,VCCalProp) != 0){
+ icalcomponent_free(container);
return 0; /* HACK. Should return an error */
}
More information about the libical-devel
mailing list