vulkaninfo: Flush before exiting
authorCharles Giessen <charles@lunarg.com>
Fri, 14 Apr 2023 21:42:31 +0000 (15:42 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Fri, 14 Apr 2023 23:07:33 +0000 (17:07 -0600)
Vulkaninfo does not manually flush the output before exiting, which means that
if a crash were to happen during teardown, the stdout buffer may not have
finished writing.

vulkaninfo/vulkaninfo.cpp

index 7119475..37c9a68 100644 (file)
@@ -1139,6 +1139,8 @@ int main(int argc, char **argv) {
 
         RunPrinter(*(printer.get()), parse_data, instance, gpus, surfaces);
 
+        // Call the printer's destructor before the file handle gets closed
+        printer.reset(nullptr);
 #if defined(VULKANINFO_WSI_ENABLED)
         for (auto &surface_extension : instance.surface_extensions) {
             AppDestroySurface(instance, surface_extension.surface);
@@ -1152,9 +1154,10 @@ int main(int argc, char **argv) {
             printer->FinishOutput();
         }
         return_code = 1;
+
+        // Call the printer's destructor before the file handle gets closed
+        printer.reset(nullptr);
     }
-    // Call the printer's destructor before the file handle gets closed
-    printer.reset(nullptr);
 
 #ifdef _WIN32
     if (parse_data.output_category == OutputCategory::text && !parse_data.print_to_file) wait_for_console_destroy();