[file-roller] Fix some memleaks
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] Fix some memleaks
- Date: Tue, 31 Aug 2010 17:24:53 +0000 (UTC)
commit 537d738ebbd8f73f4f8c4241c1c64999e6691b39
Author: Pablo Castellano <pablog src gnome org>
Date: Tue Aug 31 16:56:48 2010 +0200
Fix some memleaks
src/file-utils.c | 7 +++++--
src/java-utils.c | 12 +++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/file-utils.c b/src/file-utils.c
index e152ca0..52adb84 100644
--- a/src/file-utils.c
+++ b/src/file-utils.c
@@ -955,6 +955,7 @@ gboolean
is_temp_work_dir (const char *dir)
{
int i;
+ const char *folder;
if (strncmp (dir, "file://", 7) == 0)
dir = dir + 7;
@@ -962,14 +963,16 @@ is_temp_work_dir (const char *dir)
return FALSE;
for (i = 0; try_folder[i] != NULL; i++) {
- const char *folder;
folder = ith_temp_folder_to_try (i);
if (strncmp (dir, folder, strlen (folder)) == 0)
- if (strncmp (dir + strlen (folder), "/.fr-", 5) == 0)
+ if (strncmp (dir + strlen (folder), "/.fr-", 5) == 0) {
+ g_free (folder);
return TRUE;
+ }
}
+ g_free (folder);
return FALSE;
}
diff --git a/src/java-utils.c b/src/java-utils.c
index a5fa9c3..b48bdd0 100644
--- a/src/java-utils.c
+++ b/src/java-utils.c
@@ -162,8 +162,10 @@ load_constant_pool_utfs (JavaClassFile *cfile)
case CONST_CLASS:
class = g_new0 (struct class_info, 1);
class->index = i + 1;
- if (read (cfile->fd, &class->name_index, 2) != 2)
+ if (read (cfile->fd, &class->name_index, 2) != 2) {
+ g_free (class);
return; /* error reading */
+ }
class->name_index = GUINT16_FROM_BE (class->name_index);
cfile->const_pool_class = g_slist_append (cfile->const_pool_class, class);
break;
@@ -207,12 +209,16 @@ load_constant_pool_utfs (JavaClassFile *cfile)
case CONST_UTF8:
txt = g_new0 (struct utf_string, 1);
txt->index = i + 1;
- if (read (cfile->fd, &(txt->length), 2) == -1)
+ if (read (cfile->fd, &(txt->length), 2) == -1) {
+ g_free (txt);
return; /* error while reading */
+ }
txt->length = GUINT16_FROM_BE (txt->length);
txt->str = g_new0 (char, txt->length);
- if (read (cfile->fd, txt->str, txt->length) == -1)
+ if (read (cfile->fd, txt->str, txt->length) == -1) {
+ g_free (txt);
return; /* error while reading */
+ }
cfile->const_pool_utf = g_slist_append (cfile->const_pool_utf, txt);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]