]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3287: Check for null pointer.
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 24 Feb 2022 11:35:22 +0000 (11:35 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 24 Feb 2022 11:35:22 +0000 (11:35 +0000)
Merge in SNORT/snort3 from ~OSHUMEIK/snort3:nullptr_check to master

Squashed commit of the following:

commit 56fd2e82203634e775a3aea7c31f8643a7256665
Author: Oleksii Shumeiko <oshumeik@cisco.com>
Date:   Wed Feb 23 12:46:28 2022 +0200

    utils: check for NULL before calling fclose()

src/utils/util.cc

index e60d62a51f59660de031f9e0692f5bbffeda4071..6694e037fcfbdf7c503976f384e09f6f133d84d6 100644 (file)
@@ -207,7 +207,11 @@ void CreatePidFile(pid_t pid)
     }
     else
     {
-        fclose(pid_lockfile);
+        if (pid_lockfile)
+        {
+            fclose(pid_lockfile);
+            pid_lockfile = nullptr;
+        }
         const char* error = get_error(errno);
         ErrorMessage("Failed to create pid file %s, Error: %s\n",
             sc->pid_filename.c_str(), error);