aboutsummaryrefslogtreecommitdiff
path: root/mousmain.c
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2022-04-16 19:55:32 +0200
committerJavier <dev.git@javispedro.com>2022-04-16 19:55:32 +0200
commit9cf5dd38521565ff889dc6b07187742ac67a7454 (patch)
tree7d20fdde1a00796047ffeca56a17677ef4883d73 /mousmain.c
parent1075670224d66edba07aa5c100917f3ace7d628c (diff)
downloadvbados-9cf5dd38521565ff889dc6b07187742ac67a7454.tar.gz
vbados-9cf5dd38521565ff889dc6b07187742ac67a7454.zip
avoid leaking HMA on install error
Diffstat (limited to 'mousmain.c')
-rw-r--r--mousmain.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mousmain.c b/mousmain.c
index 93a8c0d..56b8efe 100644
--- a/mousmain.c
+++ b/mousmain.c
@@ -308,10 +308,7 @@ static __declspec(aborts) int install_driver(LPTSRDATA data, bool high)
// If we reallocated ourselves to UMB,
// it's time to free our initial conventional memory allocation
if (high) {
- // We are about to free() our own code segment.
- // Nothing should try to allocate memory between this and the TSR call
- // below, since it could overwrite our code...
- dos_free(_psp);
+ finish_reallocation(_psp, FP_SEG(data));
}
_dos_keep(EXIT_SUCCESS, get_paragraphs(resident_size));
@@ -479,7 +476,10 @@ int main(int argc, const char *argv[])
deallocate_environment(_psp);
}
err = configure_driver(data);
- if (err) return EXIT_FAILURE;
+ if (err) {
+ if (high) cancel_reallocation(FP_SEG(data));
+ return EXIT_FAILURE;
+ }
return install_driver(data, high);
} else if (stricmp(argv[argi], "uninstall") == 0) {
if (!data) return driver_not_found();