1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

Crashing in RSS code probably fixed. Memory leak in prss fixed.

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@874 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Toni Spets 2007-06-03 08:58:05 +00:00
parent b6d1465635
commit 615fb19723
3 changed files with 14 additions and 4 deletions

View File

@ -26,6 +26,8 @@
#define PARSE_OPTIONS 0
#endif
PRSS* prss_parse_doc(xmlDocPtr doc);
PRSS* prss_parse_data(const char* xml_data)
{
xmlDocPtr doc = xmlReadMemory(xml_data, strlen(xml_data), "", NULL, PARSE_OPTIONS);
@ -180,6 +182,8 @@ static inline int parse_rss_0_9x(PRSS* res, xmlNodePtr root)
PRSS* prss_parse_doc(xmlDocPtr doc)
{
// FIXME: doc shouldn't be freed after failure when called explicitly from program!
xmlNodePtr root = xmlDocGetRootElement(doc);
PRSS* result = malloc(sizeof(PRSS));
prss_null(result);
@ -190,6 +194,7 @@ PRSS* prss_parse_doc(xmlDocPtr doc)
// RSS 1.0 document
if (!parse_rss_1_0(result, root)) {
free(result);
xmlFreeDoc(doc);
return NULL;
}
return result;
@ -197,6 +202,7 @@ PRSS* prss_parse_doc(xmlDocPtr doc)
// RSS 2.0 or <1.0 document
if (!parse_rss_2_0(result, root)) {
free(result);
xmlFreeDoc(doc);
return NULL;
}
return result;

View File

@ -50,7 +50,9 @@ typedef struct PRSS_ {
/* Functions for parsing RSS-data */
PRSS* prss_parse_data(const char *xml_data);
PRSS* prss_parse_file(const char *xml_file);
PRSS* prss_parse_doc(xmlDocPtr doc);
// Works wrong currently when called from application!
//PRSS* prss_parse_doc(xmlDocPtr doc);
/* Frees the PRSS-stucture returned by prss_parse_*.
* The memory area pointed by data becomes invalid

View File

@ -112,8 +112,10 @@ get_rss_info(char *uri, int delay)
if(!rss_delay(last_update, delay))
return curdata; // wait for delay to pass
if(curdata != NULL)
if(curdata != NULL) {
prss_free(curdata); // clean up old data
curdata = NULL;
}
curl = curl_easy_init();
if(curl) {
@ -130,10 +132,10 @@ get_rss_info(char *uri, int delay)
} else
ERR("No data from server");
curfeed->data = curdata;
curl_easy_cleanup(curl);
}
curfeed->data = curdata;
return curdata;
}