Coverity fixes
[claws.git] / src / plugins / vcalendar / vcal_folder.c
index cacb55285fa45fd132fd308e7af23aaf07b9bd4f..76928f52b21b7f6860c5567de97f90c70afd6c18 100644 (file)
@@ -42,6 +42,7 @@
 #include "procheader.h"
 #include "folder.h"
 #include "folderview.h"
+#include "folder_item_prefs.h"
 #include "vcalendar.h"
 #include "vcal_folder.h"
 #include "vcal_prefs.h"
@@ -548,7 +549,7 @@ static gint feed_fetch(FolderItem *fitem, MsgNumberList ** list, gboolean *old_u
                        prop = icalcomponent_get_first_property(evt, ICAL_DTSTART_PROPERTY);
                        if (prop) {
                                ritr = icalrecur_iterator_new(recur, icalproperty_get_dtstart(prop));
-                               next = icalrecur_iterator_next(ritr); /* skip first one */                              
+                               next = icalrecur_iterator_next(ritr); /* skip first one */
                        }
                        
                        rprop = rprop2;
@@ -606,7 +607,7 @@ add_new:
                                item->evtlist = g_slist_prepend(item->evtlist, data);
                                data = NULL;
                        }
-                       if (rprop) {
+                       if (rprop && ritr) {
                                struct icaldurationtype ical_dur;
                                struct icaltimetype dtstart, dtend;
                                evt = icalcomponent_new_clone(evt);
@@ -622,7 +623,7 @@ add_new:
                                if (prop)
                                        dtend = icalproperty_get_dtend(prop);
                                ical_dur = icaltime_subtract(dtend, dtstart);
-                               next = icalrecur_iterator_next(ritr); 
+                               next = icalrecur_iterator_next(ritr);
                                if (!icaltime_is_null_time(next) &&
                                    !icaltime_is_null_time(dtstart) && i < 100) {
                                        prop = icalcomponent_get_first_property(evt, ICAL_DTSTART_PROPERTY);
@@ -1567,8 +1568,10 @@ void *url_read_thread(void *data)
        curl_easy_setopt(curl_ctx, CURLOPT_TIMEOUT, prefs_common_get_prefs()->io_timeout_secs);
        curl_easy_setopt(curl_ctx, CURLOPT_NOSIGNAL, 1);
 #if LIBCURL_VERSION_NUM >= 0x070a00
-       curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
-       curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+       if(vcalprefs.ssl_verify_peer == FALSE) {
+               curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
+               curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+       }
 #endif
        curl_easy_setopt(curl_ctx, CURLOPT_USERAGENT, 
                "Claws Mail vCalendar plugin "
@@ -1623,12 +1626,10 @@ gchar *vcal_curl_read(const char *url, const gchar *label, gboolean verbose,
        pthread_attr_t pta;
 #endif
        void *res;
-       gboolean killed;
        gchar *error = NULL;
        result = NULL;
        td = g_new0(thread_data, 1);
        res = NULL;
-       killed = FALSE;
 
        td->url  = url;
        td->result  = NULL;
@@ -1694,8 +1695,10 @@ gboolean vcal_curl_put(gchar *url, FILE *fp, gint filesize, const gchar *user, c
        curl_easy_setopt(curl_ctx, CURLOPT_READDATA, fp);
        curl_easy_setopt(curl_ctx, CURLOPT_HTTPHEADER, headers);
 #if LIBCURL_VERSION_NUM >= 0x070a00
-       curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
-       curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+       if(vcalprefs.ssl_verify_peer == FALSE) {
+               curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);
+               curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYHOST, 0);
+       }
 #endif
        curl_easy_setopt(curl_ctx, CURLOPT_USERAGENT, 
                "Claws Mail vCalendar plugin "
@@ -1841,6 +1844,19 @@ static void update_subscription_finish(const gchar *uri, gchar *feed, gboolean v
                        }
                }
                item = folder_create_folder(root->node->data, title);
+               if (!item) {
+                       if (verbose && manual_update) {
+                               alertpanel_error(_("Could not create directory %s"),
+                                       title);
+                       } else  {
+                               log_error(LOG_PROTOCOL, _("Could not create directory %s"),
+                                       title);
+                       }
+                       g_free(feed);
+                       g_free(title);
+                       main_window_cursor_normal(mainwindow_get_mainwindow());
+                       return;
+               }
                debug_print("item done %s\n", title);
                ((VCalFolderItem *)item)->uri = g_strdup(uri);
                ((VCalFolderItem *)item)->feed = feed;
@@ -1936,7 +1952,6 @@ static void unsubscribe_cal_cb(GtkAction *action, gpointer data)
        FolderItem *item;
        gchar *message;
        AlertValue avalue;
-       gchar *old_path;
        gchar *old_id;
 
        if (!folderview->selected) return;
@@ -1954,7 +1969,6 @@ static void unsubscribe_cal_cb(GtkAction *action, gpointer data)
        g_free(message);
        if (avalue != G_ALERTALTERNATE) return;
 
-       Xstrdup_a(old_path, item->path, return);
        old_id = folder_item_get_identifier(item);
 
        vcal_item_closed(item);
@@ -2058,6 +2072,9 @@ static void set_view_cb(GtkAction *gaction, GtkRadioAction *current, gpointer da
        oitem = gtk_cmctree_node_get_row_data(ctree, folderview->opened);
        item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
 
+       if (!item)
+               return;
+
        if (((VCalFolderItem *)(item))->use_cal_view == action)
                return;
        debug_print("set view %d\n", action);
@@ -2170,7 +2187,7 @@ VCalEvent *vcal_get_event_from_ical(const gchar *ical, const gchar *charset)
        gchar *recur = NULL;
        int sequence = 0;
        enum icalproperty_method method = ICAL_METHOD_REQUEST;
-       enum icalproperty_kind type = ICAL_VEVENT_COMPONENT;
+       enum icalcomponent_kind type = ICAL_VEVENT_COMPONENT;
        GSList *attendees = NULL;
        
        if (comp == NULL) {
@@ -2217,8 +2234,8 @@ VCalEvent *vcal_get_event_from_ical(const gchar *ical, const gchar *charset)
                        struct icaltimetype itt;
                        icalproperty_free(prop);
                        GET_PROP(comp, prop, ICAL_DTSTART_PROPERTY);
-                       itt = icalproperty_get_dtstart(prop);
                        if (prop) {
+                               itt = icalproperty_get_dtstart(prop);
                                icalproperty_free(prop);
                                dtend = g_strdup(icaltime_as_ical_string(icaltime_add(itt,duration)));
                                TO_UTF8(dtend);