mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-24 14:02:18 +02:00
compiler: Fix a scan-build false positive about a file handle leak
Seems scan-build is incorrectly assuming that `output != NULL` at the start of the function (so `file` is opened), and then later assuming that `output == NULL` (so `file` is not closed). Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
@@ -53,7 +53,7 @@ static gboolean
|
|||||||
write_out_typelib (gchar *prefix,
|
write_out_typelib (gchar *prefix,
|
||||||
GITypelib *typelib)
|
GITypelib *typelib)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file, *file_owned = NULL;
|
||||||
gsize written;
|
gsize written;
|
||||||
GFile *file_obj;
|
GFile *file_obj;
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
@@ -86,7 +86,7 @@ write_out_typelib (gchar *prefix,
|
|||||||
file_obj = g_file_new_for_path (filename);
|
file_obj = g_file_new_for_path (filename);
|
||||||
tmp_filename = g_strdup_printf ("%s.tmp", filename);
|
tmp_filename = g_strdup_printf ("%s.tmp", filename);
|
||||||
tmp_file_obj = g_file_new_for_path (tmp_filename);
|
tmp_file_obj = g_file_new_for_path (tmp_filename);
|
||||||
file = g_fopen (tmp_filename, "wbe");
|
file = file_owned = g_fopen (tmp_filename, "wbe");
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
@@ -106,8 +106,8 @@ write_out_typelib (gchar *prefix,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output != NULL)
|
if (file_owned != NULL)
|
||||||
fclose (file);
|
fclose (g_steal_pointer (&file_owned));
|
||||||
if (tmp_filename != NULL)
|
if (tmp_filename != NULL)
|
||||||
{
|
{
|
||||||
if (!g_file_move (tmp_file_obj, file_obj, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error))
|
if (!g_file_move (tmp_file_obj, file_obj, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error))
|
||||||
|
|||||||
Reference in New Issue
Block a user