beagle r4665 - trunk/libbeagle/beagle
- From: arunsr svn gnome org
- To: svn-commits-list gnome org
- Subject: beagle r4665 - trunk/libbeagle/beagle
- Date: Mon, 7 Apr 2008 09:10:34 +0100 (BST)
Author: arunsr
Date: Mon Apr 7 09:10:34 2008
New Revision: 4665
URL: http://svn.gnome.org/viewvc/beagle?rev=4665&view=rev
Log:
Plug a couple memory leaks
* beagle_util_get_storage_dir() had two paths, one of which allocated a
string, and one did not. We never free'd the string if it was allocated.
* We were also allocating a string for each BeagleErrorResponse and not
freeing it.
Modified:
trunk/libbeagle/beagle/beagle-error-response.c
trunk/libbeagle/beagle/beagle-util.c
Modified: trunk/libbeagle/beagle/beagle-error-response.c
==============================================================================
--- trunk/libbeagle/beagle/beagle-error-response.c (original)
+++ trunk/libbeagle/beagle/beagle-error-response.c Mon Apr 7 09:10:34 2008
@@ -51,6 +51,7 @@
BeagleErrorResponsePrivate *priv = BEAGLE_ERROR_RESPONSE_GET_PRIVATE (obj);
g_free (priv->message);
+ g_free (priv->details);
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize (obj);
Modified: trunk/libbeagle/beagle/beagle-util.c
==============================================================================
--- trunk/libbeagle/beagle/beagle-util.c (original)
+++ trunk/libbeagle/beagle/beagle-util.c Mon Apr 7 09:10:34 2008
@@ -73,14 +73,14 @@
return beagle_home;
}
-const char *
+char *
beagle_util_get_storage_dir ()
{
const char *beagle_home;
- const char *beagle_storage_dir;
+ char *beagle_storage_dir;
/* Follow the C# API: First try BEAGLE_STORAGE */
- beagle_storage_dir = g_getenv ("BEAGLE_STORAGE");
+ beagle_storage_dir = g_strdup (g_getenv ("BEAGLE_STORAGE"));
/* Then try BEAGLE_HOME/.beagle */
if (beagle_storage_dir == NULL) {
@@ -96,7 +96,7 @@
char *
beagle_util_get_socket_path (const char *client_name)
{
- const gchar *beagle_storage_dir;
+ gchar *beagle_storage_dir;
gchar *socket_dir; /* this is same as remote_storage_dir in PathFinder.cs */
gchar *socket_path;
struct stat buf;
@@ -112,11 +112,13 @@
gchar *tmp;
if (! g_file_test (remote_storage_dir_location_file, G_FILE_TEST_EXISTS)) {
+ g_free (beagle_storage_dir);
g_free (remote_storage_dir_location_file);
return NULL;
}
if (! g_file_get_contents (remote_storage_dir_location_file, &socket_dir, NULL, NULL)) {
+ g_free (beagle_storage_dir);
g_free (remote_storage_dir_location_file);
return NULL;
}
@@ -137,6 +139,7 @@
}
socket_path = g_build_filename (socket_dir, client_name, NULL);
+ g_free (beagle_storage_dir);
g_free (socket_dir);
if (stat (socket_path, &buf) == -1 || !S_ISSOCK (buf.st_mode)) {
g_free (socket_path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]