Skip to content
Permalink
Browse files

pluma-document: fix possible memory leak

  • Loading branch information...
sc0w committed Aug 24, 2018
1 parent 4d26225 commit 813e1ffd9654e3d86870ea831ea5830320077ba4
Showing with 7 additions and 11 deletions.
  1. +7 −11 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,27 +671,24 @@ file_with_bom (GFile *file)
return FALSE;
}

bom = "";

for (i = 0; i < 3; i++)
{
c = fgetc (testfile);

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

0 comments on commit 813e1ff

Please sign in to comment.
You can’t perform that action at this time.