X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=programs%2Fimagex.c;h=358e2d12a98801107350c81794f6466103eebc89;hp=5ab9aeba8ce96425e51141909011079de5470bef;hb=7bde3fc590afbdef8f71cd7f8ccbd24172bffc63;hpb=b78b15e68de3c3f9a6aed5d3514e86a72cc9c9b1 diff --git a/programs/imagex.c b/programs/imagex.c index 5ab9aeba..358e2d12 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -1779,22 +1779,28 @@ int main(int argc, const char **argv) argv++; wimlib_set_print_errors(true); + ret = wimlib_global_init(); + if (ret) + goto out; for_imagex_command(cmd) { if (strcmp(cmd->name, *argv) == 0) { ret = cmd->func(argc, argv); - if (ret > 0) { - imagex_error("Exiting with error code %d:\n" - " %s.", ret, - wimlib_get_error_string(ret)); - if (ret == WIMLIB_ERR_NTFS_3G && errno != 0) - imagex_error_with_errno("errno"); - } - return ret; + goto out; } } imagex_error("Unrecognized command: `%s'", argv[0]); usage_all(); return 1; +out: + if (ret > 0) { + imagex_error("Exiting with error code %d:\n" + " %s.", ret, + wimlib_get_error_string(ret)); + if (ret == WIMLIB_ERR_NTFS_3G && errno != 0) + imagex_error_with_errno("errno"); + } + wimlib_global_cleanup(); + return ret; }