Skip to content

Commit 813e1ff

Browse files
committed
pluma-document: fix possible memory leak
1 parent 4d26225 commit 813e1ff

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

pluma/pluma-document.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,8 @@ file_with_bom (GFile *file)
656656
FILE *testfile;
657657
gchar c;
658658
int i;
659-
gchar *bom;
659+
gchar bom[3];
660660
gchar *file_path;
661-
gboolean has_bom;
662661

663662
file_path = g_file_get_path (file);
664663

@@ -672,27 +671,24 @@ file_with_bom (GFile *file)
672671
return FALSE;
673672
}
674673

675-
bom = "";
676-
677674
for (i = 0; i < 3; i++)
678675
{
679676
c = fgetc (testfile);
680677

681678
if (c == EOF)
682679
break;
683680
else
684-
bom = g_strdup_printf ("%s%c", bom, c);
681+
bom[i] = c;
685682
}
686683

687684
fclose (testfile);
688685

689-
if (g_strcmp0 (bom, "\357\273\277") == 0)
690-
has_bom = TRUE;
686+
if ((bom[0] == '\357') &&
687+
(bom[1] == '\273') &&
688+
(bom[2] == '\277'))
689+
return TRUE;
691690
else
692-
has_bom = FALSE;
693-
694-
g_free (bom);
695-
return has_bom;
691+
return FALSE;
696692
}
697693

698694
static void

0 commit comments

Comments
 (0)