X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-folder.c;h=26b5f41f47a3e4fca22d34168a8375e2426a80e3;hp=2c0442f4d227fd5c0deac13db4cc956dd72ee3e6;hb=9e1515efeaa670ac6b01d13735fb7afb8dac0a2e;hpb=778e1ea4f05f71dfcbfd70f063ff0ad43e536060 diff --git a/src/modest-tny-folder.c b/src/modest-tny-folder.c index 2c0442f..26b5f41 100644 --- a/src/modest-tny-folder.c +++ b/src/modest-tny-folder.c @@ -538,22 +538,30 @@ modest_tny_folder_store_find_folder_from_uri (TnyFolderStore *folder_store, cons gchar *uri_to_find, *slash; gint uri_lenght; + if (uri == NULL) + return NULL; + + slash = strrchr (uri, '/'); + if (slash == NULL) + return NULL; + result = NULL; children = TNY_LIST (tny_simple_list_new ()); tny_folder_store_get_folders (folder_store, children, NULL, FALSE, NULL); - slash = strrchr (uri, '/'); uri_lenght = slash - uri + 1; uri_to_find = g_malloc0 (sizeof(char) * uri_lenght); strncpy (uri_to_find, uri, uri_lenght); uri_to_find[uri_lenght - 1] = '\0'; for (iterator = tny_list_create_iterator (children); - !tny_iterator_is_done (iterator) && (result == NULL); + iterator && !tny_iterator_is_done (iterator) && (result == NULL); tny_iterator_next (iterator)) { TnyFolderStore *child; child = TNY_FOLDER_STORE (tny_iterator_get_current (iterator)); + if (!child) + continue; if (TNY_IS_FOLDER (child)) { gchar *folder_url;