summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2018-08-24 22:49:08 +0200
committerZenWalker <[email protected]>2018-08-25 12:45:43 +0200
commit813e1ffd9654e3d86870ea831ea5830320077ba4 (patch)
treed01ff9763a92485b375b457424b4886841492139
parent4d26225d475b16de3de4aca3b6e0587d0ded3984 (diff)
downloadpluma-813e1ffd9654e3d86870ea831ea5830320077ba4.tar.bz2
pluma-813e1ffd9654e3d86870ea831ea5830320077ba4.tar.xz
pluma-document: fix possible memory leak
-rw-r--r--pluma/pluma-document.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/pluma/pluma-document.c b/pluma/pluma-document.c
index 9cc305d8..1e9ca819 100644
--- a/pluma/pluma-document.c
+++ b/pluma/pluma-document.c
@@ -656,9 +656,8 @@ file_with_bom (GFile *file)
FILE *testfile;
gchar c;
int i;
- gchar *bom;
+ gchar bom[3];
gchar *file_path;
- gboolean has_bom;
file_path = g_file_get_path (file);
@@ -672,8 +671,6 @@ file_with_bom (GFile *file)
return FALSE;
}
- bom = "";
-
for (i = 0; i < 3; i++)
{
c = fgetc (testfile);
@@ -681,18 +678,17 @@ file_with_bom (GFile *file)
if (c == EOF)
break;
else
- bom = g_strdup_printf ("%s%c", bom, c);
+ bom[i] = c;
}
fclose (testfile);
- if (g_strcmp0 (bom, "\357\273\277") == 0)
- has_bom = TRUE;
+ if ((bom[0] == '\357') &&
+ (bom[1] == '\273') &&
+ (bom[2] == '\277'))
+ return TRUE;
else
- has_bom = FALSE;
-
- g_free (bom);
- return has_bom;
+ return FALSE;
}
static void