Skip to content

Commit

Permalink
fix: exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 committed Nov 9, 2023
1 parent 8334727 commit 07f4ad5
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace {

VS_FIXEDFILEINFO* get_file_info() {
LPVOID get_file_version_info() {
DWORD zero = 0;
DWORD filename_buffer_size = MAX_PATH;
LPWSTR filename = nullptr;
Expand Down Expand Up @@ -43,18 +43,9 @@ VS_FIXEDFILEINFO* get_file_info() {
return nullptr;
}

UINT ignored = 0;
VS_FIXEDFILEINFO* file_info = nullptr;
if (!VerQueryValueW(file_ver_info, L"\\", (LPVOID*) &file_info, &ignored)) {
free(file_ver_info);
free(filename);
return nullptr;
}

free(file_ver_info);
free(filename);

return file_info;
return file_ver_info;
}

void print_help(VS_FIXEDFILEINFO* file_info) {
Expand Down Expand Up @@ -105,13 +96,17 @@ int wmain(int argc, const wchar_t* argv[]) {
if (argc == 1 ||
(argc == 2 && wcscmp(argv[1], L"-h") == 0) ||
(argc == 2 && wcscmp(argv[1], L"--help") == 0)) {
VS_FIXEDFILEINFO* file_info = get_file_info();
if (file_info == nullptr) {
UINT ignored = 0;
VS_FIXEDFILEINFO* file_info = nullptr;
LPVOID file_version_info = get_file_version_info();

if (file_version_info == nullptr || !VerQueryValueW(file_version_info, L"\\", (LPVOID*) &file_info, &ignored)) {
free(file_version_info);
return print_error("Could not determine version of rcedit");
}

print_help(file_info);
free(file_info);
free(file_version_info);
return 0;
}

Expand Down

0 comments on commit 07f4ad5

Please sign in to comment.