Wow. Such data, so leak, very unfreed
[claws.git] / src / plugins / vcalendar / libical / libical / icalcomponent.c
index b723086f9c909b3dc18d2bfe7d1875a15658dcfa..c027ee99674d093e545f3729eaf980ba28589872 100644 (file)
@@ -254,9 +254,6 @@ icalcomponent_as_ical_string (icalcomponent* component)
 
    const char* kind_string;
 
-   buf = icalmemory_new_buffer(buf_size);
-   buf_ptr = buf; 
-
    icalerror_check_arg_rz( (component!=0), "component");
    icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT");
    
@@ -264,6 +261,9 @@ icalcomponent_as_ical_string (icalcomponent* component)
 
    icalerror_check_arg_rz( (kind_string!=0),"Unknown kind of component");
 
+   buf = icalmemory_new_buffer(buf_size);
+   buf_ptr = buf; 
+
    icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:");
    icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
    icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
@@ -301,7 +301,7 @@ icalcomponent_as_ical_string (icalcomponent* component)
    icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
 
    out_buf = icalmemory_tmp_copy(buf);
-   free(buf);
+   icalmemory_free_buffer(buf);
 
    return out_buf;
 }