Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pluma-document: fix possible memory leak
  • Loading branch information
sc0w committed Aug 25, 2018
1 parent 4d26225 commit 813e1ff
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pluma/pluma-document.c
Expand Up @@ -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);

Expand All @@ -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
Expand Down

0 comments on commit 813e1ff

Please sign in to comment.