[Commits] [SCM] claws branch, master, updated. 3.17.3-168-ged39558

ticho at claws-mail.org ticho at claws-mail.org
Sun Apr 28 23:15:34 CEST 2019


The branch, master has been updated
       via  ed39558ac116e480cdbe18a6ee6c5602150994cb (commit)
      from  fe278b3cc9209a1b34024658467f4dd6e467b97a (commit)

Summary of changes:
 src/plugins/rssyl/parse822.c |   26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)


- Log -----------------------------------------------------------------
commit ed39558ac116e480cdbe18a6ee6c5602150994cb
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Apr 28 23:13:32 2019 +0200

    Simplify item body parsing in rssyl_parse_folder_item_file()
    
    This possibly fixes a memory corruption issue, too.

diff --git a/src/plugins/rssyl/parse822.c b/src/plugins/rssyl/parse822.c
index 4732afa..0553de6 100644
--- a/src/plugins/rssyl/parse822.c
+++ b/src/plugins/rssyl/parse822.c
@@ -55,6 +55,7 @@ FeedItem *rssyl_parse_folder_item_file(gchar *path)
 	FeedItem *item;
 	RFeedCtx *ctx;
 	gint i = 0;
+	GString *body = NULL;
 	gboolean parsing_headers = TRUE, past_html_tag = FALSE, past_endhtml_tag = FALSE;
 	gboolean started_author = FALSE, started_subject = FALSE;
 	gboolean started_link = FALSE, started_clink = FALSE, got_original_title = FALSE;
@@ -207,26 +208,29 @@ FeedItem *rssyl_parse_folder_item_file(gchar *path)
 					i++;
 					continue;
 				}
-				if( feed_item_get_text(item) != NULL ) {
-					gint e_len, n_len;
-					e_len = strlen(item->text);
-					n_len = strlen(lines[i]);
-					item->text = g_realloc(item->text, e_len + n_len + 2);
-					*(item->text+e_len) = '\n';
-					strcpy(item->text+e_len+1, lines[i]);
-					*(item->text+e_len+n_len+1) = '\0';
+
+				if (body) {
+					debug_print("appending '%s'\n", lines[i]);
+					body = g_string_append(body, lines[i]);
 				} else {
-					item->text = g_strdup(lines[i]);
+					debug_print("creating new with '%s'\n", lines[i]);
+					body = g_string_new(lines[i]);
 				}
+
 				i++;
 			}
 
-			if( lines[i] == NULL )
-				return item;
 		}
 
 		i++;
 	}
+
+	if (body != NULL ) {
+		if (past_endhtml_tag && body->str != NULL && body->len > 0)
+			feed_item_set_text(item, body->str);
+		g_string_free(body, TRUE);
+	}
+
 	g_free(lines);
 	g_free(contents);
 	return item;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list