From 2712a79c55685d1347a3495ca043264b166b0302 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 3 Apr 2024 17:56:52 +0200 Subject: [PATCH] vkd3d-dxbc: Close output files after writing them. --- programs/vkd3d-dxbc/main.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/programs/vkd3d-dxbc/main.c b/programs/vkd3d-dxbc/main.c index efe0a8fd..6d065f3b 100644 --- a/programs/vkd3d-dxbc/main.c +++ b/programs/vkd3d-dxbc/main.c @@ -514,6 +514,7 @@ int main(int argc, char **argv) FILE *input, *output; char *messages; uint32_t flags; + bool success; int fail = 1; size_t i; int ret; @@ -583,18 +584,15 @@ int main(int argc, char **argv) goto done; } - if (!write_output(output, &serialized)) - { + if (!(success = write_output(output, &serialized))) fprintf(stderr, "Failed to write output blob.\n"); - vkd3d_shader_free_shader_code(&serialized); - goto done; - } + if (close_output) + fclose(output); vkd3d_shader_free_shader_code(&serialized); + if (!success) + goto done; break; - - default: - vkd3d_unreachable(); } } @@ -605,7 +603,5 @@ done: free(options.actions); if (close_input) fclose(input); - if (close_output) - fclose(output); return fail; }