OSDN Git Service

Merge "libril: Protect against NULL unsolicited response function"
authorTreehugger Robot <treehugger-gerrit@google.com>
Mon, 12 Mar 2018 20:35:37 +0000 (20:35 +0000)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Mon, 12 Mar 2018 20:35:37 +0000 (20:35 +0000)
1  2 
libril/ril.cpp

diff --cc libril/ril.cpp
@@@ -780,21 -770,14 +780,23 @@@ void RIL_onUnsolicitedResponse(int unso
      }
  
      pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock((int) soc_id);
 -    int rwlockRet = pthread_rwlock_rdlock(radioServiceRwlockPtr);
 -    assert(rwlockRet == 0);
 +    int rwlockRet;
 +
 +    if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) {
 +        // get a write lock in caes of NITZ since setNitzTimeReceived() is called
 +        rwlockRet = pthread_rwlock_wrlock(radioServiceRwlockPtr);
 +        assert(rwlockRet == 0);
 +        radio::setNitzTimeReceived((int) soc_id, android::elapsedRealtime());
 +    } else {
 +        rwlockRet = pthread_rwlock_rdlock(radioServiceRwlockPtr);
 +        assert(rwlockRet == 0);
 +    }
  
-     ret = s_unsolResponses[unsolResponseIndex].responseFunction(
-             (int) soc_id, responseType, 0, RIL_E_SUCCESS, const_cast<void*>(data),
-             datalen);
+     if (s_unsolResponses[unsolResponseIndex].responseFunction) {
+         ret = s_unsolResponses[unsolResponseIndex].responseFunction(
+                 (int) soc_id, responseType, 0, RIL_E_SUCCESS, const_cast<void*>(data),
+                 datalen);
+     }
  
      rwlockRet = pthread_rwlock_unlock(radioServiceRwlockPtr);
      assert(rwlockRet == 0);