From 9b36c5b2b8ab04152f68db9dd1cd8c5ebf58b5b9 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 23 Jul 2021 16:50:12 +0000 Subject: [PATCH] libdnet: Remove call to FreeLibrary after GetModuleHandle. Per Windows API docs: "do not pass a handle returned by GetModuleHandle to the FreeLibrary function. Doing so can cause a DLL module to be unmapped prematurely." --- libdnet-stripped/NMAP_MODIFICATIONS | 18 ++++++++++++++++++ libdnet-stripped/src/route-win32.c | 2 -- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libdnet-stripped/NMAP_MODIFICATIONS b/libdnet-stripped/NMAP_MODIFICATIONS index cef8a6d60..25b3e8437 100644 --- a/libdnet-stripped/NMAP_MODIFICATIONS +++ b/libdnet-stripped/NMAP_MODIFICATIONS @@ -2543,3 +2543,21 @@ index 1399db2..352da4c 100644 if (strcmp(name, a->AdapterName) == 0) break; } + +o Remove call to FreeLibrary after GetModuleHandle. Windows API docs say: +"do not pass a handle returned by GetModuleHandle to the FreeLibrary function. +Doing so can cause a DLL module to be unmapped prematurely." + +diff --git a/libdnet-stripped/src/route-win32.c b/libdnet-stripped/src/route-win32.c +index c69b29b..8a9d2bc 100644 +--- a/libdnet-stripped/src/route-win32.c ++++ b/libdnet-stripped/src/route-win32.c +@@ -269,8 +269,6 @@ route_t * + route_close(route_t *r) + { + if (r != NULL) { +- if (r->iphlpapi != NULL) +- FreeLibrary(r->iphlpapi); + if (r->ipftable != NULL) + free(r->ipftable); + if (r->ipftable2 != NULL) diff --git a/libdnet-stripped/src/route-win32.c b/libdnet-stripped/src/route-win32.c index c69b29bfb..8a9d2bc3a 100644 --- a/libdnet-stripped/src/route-win32.c +++ b/libdnet-stripped/src/route-win32.c @@ -269,8 +269,6 @@ route_t * route_close(route_t *r) { if (r != NULL) { - if (r->iphlpapi != NULL) - FreeLibrary(r->iphlpapi); if (r->ipftable != NULL) free(r->ipftable); if (r->ipftable2 != NULL)