evolution-data-server r9773 - in trunk/calendar: . backends/caldav
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9773 - in trunk/calendar: . backends/caldav
- Date: Wed, 19 Nov 2008 11:19:48 +0000 (UTC)
Author: mcrha
Date: Wed Nov 19 11:19:48 2008
New Revision: 9773
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9773&view=rev
Log:
2008-11-19 Andrew McMillan <andrew morphoss com>
** Fix for bug #560981
* backends/caldav/e-cal-backend-caldav.c: (xp_object_get_string),
(xp_object_get_href), (xp_object_get_etag), (xp_object_get_status),
(xp_object_get_number), (parse_report_response):
Plug memory leaks from unfreed xpath query results.
Modified:
trunk/calendar/ChangeLog
trunk/calendar/backends/caldav/e-cal-backend-caldav.c
Modified: trunk/calendar/backends/caldav/e-cal-backend-caldav.c
==============================================================================
--- trunk/calendar/backends/caldav/e-cal-backend-caldav.c (original)
+++ trunk/calendar/backends/caldav/e-cal-backend-caldav.c Wed Nov 19 11:19:48 2008
@@ -542,13 +542,14 @@
static char *
xp_object_get_string (xmlXPathObjectPtr result)
{
- char *ret;
+ char *ret = NULL;
- if (result == NULL || result->type != XPATH_STRING) {
- return NULL;
- }
+ if (result == NULL)
+ return ret;
- ret = g_strdup ((char *) result->stringval);
+ if (result->type == XPATH_STRING) {
+ ret = g_strdup ((char *) result->stringval);
+ }
xmlXPathFreeObject (result);
return ret;
@@ -559,23 +560,24 @@
static char *
xp_object_get_href (xmlXPathObjectPtr result)
{
- char *ret;
+ char *ret = NULL;
char *val;
- if (result == NULL || result->type != XPATH_STRING) {
- return NULL;
- }
+ if (result == NULL)
+ return ret;
- val = (char *) result->stringval;
+ if (result->type == XPATH_STRING) {
+ val = (char *) result->stringval;
- if ((ret = g_strrstr (val, "/")) == NULL) {
- ret = val;
- } else {
- ret++; /* skip the unwanted "/" */
- }
+ if ((ret = g_strrstr (val, "/")) == NULL) {
+ ret = val;
+ } else {
+ ret++; /* skip the unwanted "/" */
+ }
- ret = g_strdup (ret);
- d(g_debug ("found href: %s", ret));
+ ret = g_strdup (ret);
+ d(g_debug ("found href: %s", ret));
+ }
xmlXPathFreeObject (result);
return ret;
@@ -585,16 +587,17 @@
static char *
xp_object_get_etag (xmlXPathObjectPtr result)
{
- char *ret;
+ char *ret = NULL;
char *str;
- if (result == NULL || result->type != XPATH_STRING) {
- return NULL;
- }
+ if (result == NULL)
+ return ret;
- str = (char *) result->stringval;
+ if (result->type == XPATH_STRING) {
+ str = (char *) result->stringval;
- ret = quote_etag (str);
+ ret = quote_etag (str);
+ }
xmlXPathFreeObject (result);
return ret;
@@ -604,20 +607,20 @@
xp_object_get_status (xmlXPathObjectPtr result)
{
gboolean res;
- guint ret;
+ guint ret = 0;
+ if (result == NULL)
+ return ret;
- if (result == NULL || result->type != XPATH_STRING) {
- return 0;
- }
-
- res = soup_headers_parse_status_line ((char *) result->stringval,
- NULL,
- &ret,
- NULL);
+ if (result->type == XPATH_STRING) {
+ res = soup_headers_parse_status_line ((char *) result->stringval,
+ NULL,
+ &ret,
+ NULL);
- if (res != TRUE) {
- ret = 0;
+ if (res != TRUE) {
+ ret = 0;
+ }
}
xmlXPathFreeObject (result);
@@ -628,13 +631,14 @@
static int
xp_object_get_number (xmlXPathObjectPtr result)
{
- int ret;
+ int ret = -1;
- if (result == NULL || result->type != XPATH_STRING) {
- return -1;
- }
+ if (result == NULL)
+ return ret;
- ret = result->boolval;
+ if (result->type == XPATH_STRING) {
+ ret = result->boolval;
+ }
xmlXPathFreeObject (result);
return ret;
@@ -750,6 +754,8 @@
}
out:
+ if (result != NULL)
+ xmlXPathFreeObject (result);
xmlXPathFreeContext (xpctx);
xmlFreeDoc (doc);
return res;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]