mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-21 21:01:07 +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,
|
||||
GITypelib *typelib)
|
||||
{
|
||||
FILE *file;
|
||||
FILE *file, *file_owned = NULL;
|
||||
gsize written;
|
||||
GFile *file_obj;
|
||||
gchar *filename;
|
||||
@@ -86,7 +86,7 @@ write_out_typelib (gchar *prefix,
|
||||
file_obj = g_file_new_for_path (filename);
|
||||
tmp_filename = g_strdup_printf ("%s.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)
|
||||
{
|
||||
@@ -106,8 +106,8 @@ write_out_typelib (gchar *prefix,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (output != NULL)
|
||||
fclose (file);
|
||||
if (file_owned != NULL)
|
||||
fclose (g_steal_pointer (&file_owned));
|
||||
if (tmp_filename != NULL)
|
||||
{
|
||||
if (!g_file_move (tmp_file_obj, file_obj, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error))
|
||||
|
Reference in New Issue
Block a user