/* Cleanup, we should be done. */
XML_ParserFree(feed_ctx->parser);
- g_free(feed_ctx->name);
- g_free(feed_ctx->mail);
+ if (feed_ctx->name != NULL)
+ g_free(feed_ctx->name);
+ if (feed_ctx->mail != NULL)
+ g_free(feed_ctx->mail);
if (feed_ctx->str != NULL)
g_string_free(feed_ctx->str, TRUE);
if (feed_ctx->xhtml_str != NULL)
XML_SetUnknownEncodingHandler(ctx->parser,
feed_parser_unknown_encoding_handler, NULL);
- g_file_get_contents(path, &contents, NULL, &error);
-
- if( error || !contents )
- return;
+ if( !g_file_get_contents(path, &contents, NULL, &error) ) {
+ g_warning("error: '%s'", error->message);
+ g_error_free(error);
+ }
+ if( contents ) {
/*
- lines = g_strsplit(contents, '\n', 0);
+ lines = g_strsplit(contents, '\n', 0);
- while( lines[i] ) {
- status = XML_Parse(ctx->parser, lines[i], strlen(lines[i]), FALSE);
- if( status == XML_STATUS_ERROR ) {
- err = XML_GetErrorCode(ctx->parser);
- sprintf(stderr, "\nExpat: --- %s\n\n", XML_ErrorString(err));
+ while( lines[i] ) {
+ status = XML_Parse(ctx->parser, lines[i], strlen(lines[i]), FALSE);
+ if( status == XML_STATUS_ERROR ) {
+ err = XML_GetErrorCode(ctx->parser);
+ sprintf(stderr, "\nExpat: --- %s\n\n", XML_ErrorString(err));
+ }
}
- }
*/
-
- status = XML_Parse(ctx->parser, contents, strlen(contents), FALSE);
- err = XML_GetErrorCode(ctx->parser);
- fprintf(stderr, "\nExpat: --- %s (%s)\n\n", XML_ErrorString(err),
+ status = XML_Parse(ctx->parser, contents, strlen(contents), FALSE);
+ err = XML_GetErrorCode(ctx->parser);
+ fprintf(stderr, "\nExpat: --- %s (%s)\n\n", XML_ErrorString(err),
(status == XML_STATUS_OK ? "OK" : "NOT OK"));
- XML_Parse(ctx->parser, "", 0, TRUE);
+ XML_Parse(ctx->parser, "", 0, TRUE);
+ }
XML_ParserFree(ctx->parser);
+ if (ctx->str != NULL)
+ g_string_free(ctx->str, TRUE);
g_free(ctx);
}
debug_print("RSSyl: parsing '%s'\n", path);
- g_file_get_contents(path, &contents, NULL, &error);
-
- if( error ) {
+ if( !g_file_get_contents(path, &contents, NULL, &error) ) {
g_warning("error: '%s'", error->message);
g_error_free(error);
}
if( !strcmp(lines[i], RSSYL_TEXT_START) ) {
debug_print("RSSyl: Leading html tag found at line %d\n", i);
past_html_tag = TRUE;
+ if (body)
+ {
+ g_warning("unexpected leading html tag found at line %d", i);
+ g_string_free(body, TRUE);
+ }
body = g_string_new("");
i++;
continue;
static void rssyl_copy_private_data(Folder *folder, FolderItem *oldi,
FolderItem *newi)
{
- gchar *dpathold, *dpathnew;
+ gchar *dpathold, *dpathnew, *pathold, *pathnew;
RFolderItem *olditem = (RFolderItem *)oldi,
*newitem = (RFolderItem *)newi;
newitem->fetching_comments = olditem->fetching_comments;
newitem->last_update = olditem->last_update;
- dpathold = g_strconcat(rssyl_item_get_path(oldi->folder, oldi),
- G_DIR_SEPARATOR_S, RSSYL_DELETED_FILE, NULL);
- dpathnew = g_strconcat(rssyl_item_get_path(newi->folder, newi),
- G_DIR_SEPARATOR_S, RSSYL_DELETED_FILE, NULL);
+ pathold = rssyl_item_get_path(oldi->folder, oldi);
+ dpathold = g_strconcat(pathold, G_DIR_SEPARATOR_S, RSSYL_DELETED_FILE, NULL);
+ pathnew = rssyl_item_get_path(newi->folder, newi);
+ dpathnew = g_strconcat(pathnew, G_DIR_SEPARATOR_S, RSSYL_DELETED_FILE, NULL);
move_file(dpathold, dpathnew, TRUE);
+ g_free(pathold);
+ g_free(pathnew);
g_free(dpathold);
g_free(dpathnew);
return;
}
- g_free(deleted_file);
-
while (lines[i]) {
line = g_strsplit(lines[i], ": ", 2);
if (line[0] && line[1] && strlen(line[0]) && strlen(line[1])) {
g_strfreev(line);
i++;
}
+ if (ditem)
+ g_warning("short read while parsing the list of deleted items for '%s'\n",
+ deleted_file);
+ g_free(deleted_file);
g_free(lines);
g_free(contents);
if( (num = to_number(d)) > 0) {
fname = g_strdup_printf("%s%c%s", path, G_DIR_SEPARATOR, d);
- if (!g_file_test(fname, G_FILE_TEST_IS_REGULAR))
+ if (!g_file_test(fname, G_FILE_TEST_IS_REGULAR)) {
+ g_free(fname);
continue;
+ }
debug_print("RSSyl: starting to parse '%s'\n", d);
if ((d = g_dir_open(oldpath, 0, &error)) == NULL) {
debug_print("RSSyl: (FORMAT) couldn't open dir '%s': %s\n", oldpath,
error->message);
+ g_free(oldpath);
+ g_free(newpath);
g_error_free(error);
return;
}