summaryrefslogtreecommitdiff
path: root/libcaja-private/caja-link.c
diff options
context:
space:
mode:
authorMonsta <[email protected]>2014-12-03 16:05:43 +0300
committerinfirit <[email protected]>2014-12-10 10:38:37 +0100
commit523ca6754f1f1f5e86367c644bb721b20f5fbebd (patch)
treec34b3bae093a37a7d7594cc4efa3168726ce5340 /libcaja-private/caja-link.c
parent78661bd703b26343621b209f4f13e5e9fcbad802 (diff)
downloadcaja-523ca6754f1f1f5e86367c644bb721b20f5fbebd.tar.bz2
caja-523ca6754f1f1f5e86367c644bb721b20f5fbebd.tar.xz
libcaja-private: don't leak memory
Diffstat (limited to 'libcaja-private/caja-link.c')
-rw-r--r--libcaja-private/caja-link.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/libcaja-private/caja-link.c b/libcaja-private/caja-link.c
index 89971772..4f39a474 100644
--- a/libcaja-private/caja-link.c
+++ b/libcaja-private/caja-link.c
@@ -416,19 +416,14 @@ caja_link_local_get_additional_text (const char *path)
static char *
caja_link_get_link_uri_from_desktop (GKeyFile *key_file, const char *desktop_file_uri)
{
- GFile *file, *parent;
- char *type;
- char *retval;
- char *scheme;
-
- retval = NULL;
-
- type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL);
+ char *type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL);
if (type == NULL)
{
return NULL;
}
+ char *retval = NULL;
+
if (strcmp (type, "URL") == 0)
{
/* Some old broken desktop files use this nonstandard feature, we need handle it though */
@@ -450,11 +445,11 @@ caja_link_get_link_uri_from_desktop (GKeyFile *key_file, const char *desktop_fil
* g_file_parse_name(), but it does not know how to resolve
* relative file names, since the base directory is unknown.
*/
- scheme = g_uri_parse_scheme (retval);
+ char *scheme = g_uri_parse_scheme (retval);
if (scheme == NULL)
{
- file = g_file_new_for_uri (desktop_file_uri);
- parent = g_file_get_parent (file);
+ GFile *file = g_file_new_for_uri (desktop_file_uri);
+ GFile *parent = g_file_get_parent (file);
g_object_unref (file);
if (parent != NULL)
@@ -466,6 +461,10 @@ caja_link_get_link_uri_from_desktop (GKeyFile *key_file, const char *desktop_fil
g_object_unref (parent);
}
}
+ else
+ {
+ g_free (scheme);
+ }
}
return retval;