From 75f6b387feed122175e5a2cf73cb24bfb98944b0 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 4 Sep 2024 18:41:44 +0000 Subject: [PATCH] Don't call WSACleanup if WSAStartup wasn't called --- mswin32/winfix.cc | 2 +- nping/winfix.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mswin32/winfix.cc b/mswin32/winfix.cc index e192ab8bb..8b64f0c5c 100644 --- a/mswin32/winfix.cc +++ b/mswin32/winfix.cc @@ -93,6 +93,7 @@ void win_pre_init() { werd = MAKEWORD( 2, 2 ); if( (WSAStartup(werd, &data)) !=0 ) fatal("failed to start winsock.\n"); + atexit(win_cleanup); } /* Check if the NPCAP service is running on Windows, and try to start it if it's @@ -258,7 +259,6 @@ void win_init() if (!o.have_pcap) o.isr00t = 0; - atexit(win_cleanup); } diff --git a/nping/winfix.cc b/nping/winfix.cc index e56af909d..7aa2a8a89 100644 --- a/nping/winfix.cc +++ b/nping/winfix.cc @@ -91,6 +91,7 @@ void win_pre_init() { werd = MAKEWORD( 2, 2 ); if( (WSAStartup(werd, &data)) !=0 ) fatal("failed to start winsock.\n"); + atexit(win_cleanup); } /* Check if the NPCAP service is running on Windows, and try to start it if it's @@ -255,7 +256,6 @@ void win_init() if (!o.havePcap()) o.setIsRoot(0); - atexit(win_cleanup); }