diff options
author | Kévin Petit <kevin.petit@arm.com> | 2014-10-09 15:20:56 +0100 |
---|---|---|
committer | Kévin Petit <kevin.petit@arm.com> | 2014-10-09 15:20:56 +0100 |
commit | ad71392ad47a3918abeeaa639020dfb63d4fe510 (patch) | |
tree | 4f2a03b9781432884830c81d0d59fb75de813d4e | |
parent | 100457df47b8a453eb94df3cf2e87f6248e783d1 (diff) | |
download | netd-ad71392ad47a3918abeeaa639020dfb63d4fe510.tar.gz |
Fix MDnsSdListener::Monitor::Monitor()
* Initialisation of mLiveCount
The value of mLiveCount was being used without being initialised, and
this was causing the CTS class android.net.wifi.cts.NsdManagerTest
method testAndroidTestCaseSetupProperly test to fail when the calls
to calloc in the MDnsSdListener::Monitor::rescan() method returned a
value of NULL due to the large value of mPollSize, which had been set
to "mLiveCount + 5". The mPollFds and mPollRefs pointers were then used
without checking that they were not NULL, resulting in a segmentation
violation when the NULL pointer value was dereferenced. Initialising
the value of mLiveCount to zero in MDnsSdListener::Monitor::Monitor()
fixes this problem, and the test then passes.
* Also initilize mPollFds, mPollRefs and mPollSize
Change-Id: I1a8f7ee0f3ed38f46854e9ba6d5c432c9412b7c3
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Kévin Petit <kevin.petit@arm.com>
-rw-r--r-- | MDnsSdListener.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/MDnsSdListener.cpp b/MDnsSdListener.cpp index 3134e3db..c693c2a1 100644 --- a/MDnsSdListener.cpp +++ b/MDnsSdListener.cpp @@ -496,6 +496,10 @@ MDnsSdListener::Monitor::Monitor() { mHead = NULL; pthread_mutex_init(&mHeadMutex, NULL); socketpair(AF_LOCAL, SOCK_STREAM, 0, mCtrlSocketPair); + mLiveCount = 0; + mPollFds = NULL; + mPollRefs = NULL; + mPollSize = 10; pthread_create(&mThread, NULL, MDnsSdListener::Monitor::threadStart, this); pthread_detach(mThread); } |