blob: d64fb35db11bf504c607b4d69c90d85c7536c5ca [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From 19de26db69408f02241e232b39224589a0f630df Mon Sep 17 00:00:00 2001
2From: Nate Karstens <nate.karstens@garmin.com>
3Date: Thu, 10 Aug 2017 08:46:03 -0500
4Subject: [PATCH 11/11] Change a dynamic allocation to file-scope variable
5
6Changes a variable from being dynamically-allocated to being
7statically-allocated at the file scope. Addresses a Coverity
8issue where it appeared that the memory was being leaked.
9
10Upstream-Status: Submitted [dts@apple.com]
11
12Signed-off-by: Nate Karstens <nate.karstens@garmin.com>
13---
14 mDNSPosix/mDNSPosix.c | 12 ++++--------
15 1 file changed, 4 insertions(+), 8 deletions(-)
16
17diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c
18index 84af26b..b7795ed 100644
19--- a/mDNSPosix/mDNSPosix.c
20+++ b/mDNSPosix/mDNSPosix.c
21@@ -91,6 +91,7 @@ static sigset_t gEventSignalSet; // Signals which event loop list
22 static sigset_t gEventSignals; // Signals which were received while inside loop
23
24 static PosixNetworkInterface *gRecentInterfaces;
25+static IfChangeRec gChgRec;
26
27 // ***************************************************************************
28 // Globals (for debugging)
29@@ -1412,16 +1413,11 @@ cleanup:
30 mDNSlocal mStatus WatchForInterfaceChange(mDNS *const m)
31 {
32 mStatus err;
33- IfChangeRec *pChgRec;
34
35- pChgRec = (IfChangeRec*) mDNSPlatformMemAllocate(sizeof *pChgRec);
36- if (pChgRec == NULL)
37- return mStatus_NoMemoryErr;
38-
39- pChgRec->mDNS = m;
40- err = OpenIfNotifySocket(&pChgRec->NotifySD);
41+ gChgRec.mDNS = m;
42+ err = OpenIfNotifySocket(&gChgRec.NotifySD);
43 if (err == 0)
44- err = mDNSPosixAddFDToEventLoop(pChgRec->NotifySD, InterfaceChangeCallback, pChgRec);
45+ err = mDNSPosixAddFDToEventLoop(gChgRec.NotifySD, InterfaceChangeCallback, &gChgRec);
46
47 return err;
48 }
49--
502.17.1
51