RSSClient: actualy use the precalculated length for the StrBuf allocation
[citadel.git] / citadel / modules / rssclient / rss_atom_parser.c
index c33fe9e707643c3f8ff9b9c78c278097db74b9da..86346296244eb3504d1f7b5bccaa532b9b805a50 100644 (file)
@@ -745,7 +745,7 @@ void rss_save_item(rss_item *ri, rss_aggregator *RSSAggr)
                len = StrLength(ri->title);
                Sbj = html_to_ascii(ChrPtr(ri->title), len, 512, 0);
                len = strlen(Sbj);
-               if (Sbj[len - 1] == '\n')
+               if ((len > 0) && (Sbj[len - 1] == '\n'))
                {
                        len --;
                        Sbj[len] = '\0';
@@ -777,7 +777,7 @@ void rss_save_item(rss_item *ri, rss_aggregator *RSSAggr)
 
        msglen += 1024 + StrLength(ri->link) + StrLength(ri->description) ;
 
-       Message = NewStrBufPlain(NULL, StrLength(ri->description));
+       Message = NewStrBufPlain(NULL, msglen);
 
        StrBufPlain(Message, HKEY(
                            "Content-type: text/html; charset=\"UTF-8\"\r\n\r\n"