[evolution] M!26 - evolution-csv-importer.c:getNextCSVEntry() memory leak
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] M!26 - evolution-csv-importer.c:getNextCSVEntry() memory leak
- Date: Mon, 8 Jul 2019 13:44:47 +0000 (UTC)
commit 173fe68070ac560d93adc6e87fe5e54c89619c92
Author: Дилян Палаузов <git-dpa aegee org>
Date: Sun Jul 7 17:18:19 2019 +0000
M!26 - evolution-csv-importer.c:getNextCSVEntry() memory leak
Closes https://gitlab.gnome.org/GNOME/evolution/merge_requests/26
src/addressbook/importers/evolution-csv-importer.c | 39 +++++++++-------------
1 file changed, 15 insertions(+), 24 deletions(-)
---
diff --git a/src/addressbook/importers/evolution-csv-importer.c
b/src/addressbook/importers/evolution-csv-importer.c
index f4340976ee..8385d1dba5 100644
--- a/src/addressbook/importers/evolution-csv-importer.c
+++ b/src/addressbook/importers/evolution-csv-importer.c
@@ -641,16 +641,16 @@ getNextCSVEntry (CSVImporter *gci,
FILE *f)
{
EContact *contact = NULL;
- GString *line;
- GString *str;
- gchar *buf;
+ GString *line;
gint c;
line = g_string_new ("");
while (1) {
c = fgetc (f);
- if (c == EOF)
+ if (c == EOF) {
+ g_string_free (line, TRUE);
return NULL;
+ }
if (c == '\n') {
g_string_append_c (line, c);
break;
@@ -662,20 +662,19 @@ getNextCSVEntry (CSVImporter *gci,
g_string_append_c (line, c);
c = fgetc (f);
}
- g_string_append_c (line, c);
}
- else
- g_string_append_c (line, c);
+ g_string_append_c (line, c);
}
if (gci->count == 0 && importer != MOZILLA_IMPORTER) {
gci->fields_map = map_fields (line->str, importer);
- g_string_free (line, TRUE);
- line = g_string_new ("");
+ g_string_set_size (line, 0);
while (1) {
c = fgetc (f);
- if (c == EOF)
+ if (c == EOF) {
+ g_string_free (line, TRUE);
return NULL;
+ }
if (c == '\n') {
g_string_append_c (line, c);
break;
@@ -687,35 +686,27 @@ getNextCSVEntry (CSVImporter *gci,
g_string_append_c (line, c);
c = fgetc (f);
}
- g_string_append_c (line, c);
}
- else
- g_string_append_c (line, c);
+ g_string_append_c (line, c);
}
gci->count++;
}
- str = g_string_new ("");
- str = g_string_append (str, line->str);
-
- g_string_free (line, TRUE);
-
- if (strlen (str->str) == 0) {
- g_string_free (str, TRUE);
+ if (line->len == 0) {
+ g_string_free (line, TRUE);
return NULL;
}
contact = e_contact_new ();
- buf = str->str;
-
- if (!parseLine (gci, contact, buf)) {
+ if (!parseLine (gci, contact, line->str)) {
g_object_unref (contact);
+ g_string_free (line, TRUE);
return NULL;
}
gci->count++;
- g_string_free (str, TRUE);
+ g_string_free (line, TRUE);
return contact;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]