diff --git a/tools/vtable_scanner/main.cpp b/tools/vtable_scanner/main.cpp index 693a459b..59ba8761 100644 --- a/tools/vtable_scanner/main.cpp +++ b/tools/vtable_scanner/main.cpp @@ -18,7 +18,6 @@ int main(int argc, char **argv) { void *handle; void **pVtable; - handle = dlopen(argv[1], RTLD_NOW); VOffset offsets; char *params = NULL; @@ -30,6 +29,8 @@ int main(int argc, char **argv) return -1; } + handle = dlopen(argv[1], RTLD_NOW); + if (handle == NULL) { fprintf(stderr, "Failed to open server image, error [%s]\n", dlerror()); @@ -41,6 +42,7 @@ int main(int argc, char **argv) if (pVtable == NULL) { fprintf(stderr, "Invalid vtable symbol \"%s\"\n", argv[2]); + dlclose(handle); return -1; } @@ -86,10 +88,12 @@ int main(int argc, char **argv) printf("%s - Win: %i Linux : %i\n", argv[3], offsets.windows_offset, offsets.linux_offset); } + dlclose(handle); return 0; } fprintf(stderr, "Failed to find function!"); + dlclose(handle); return -1; } @@ -175,8 +179,6 @@ static bool FindVFunc(void *handle, void **vtable, const char* vtable_end, const windows_offset = (overloads-location) + start_offset; - dlclose(handle); - offsets->linux_offset = linux_offset - 2; offsets->windows_offset = windows_offset - 2;