[IOT-2314] De-reference pResponse done after null check. 19/20319/3
authorSushil Yadav <sushil.ky@samsung.com>
Tue, 23 May 2017 10:34:20 +0000 (16:04 +0530)
committerUze Choi <uzchoi@samsung.com>
Wed, 24 May 2017 01:39:19 +0000 (01:39 +0000)
In InProcServerWrapper::sendReponse() pResponse tries to dereference before
checking for the null. The bug was introduced for as part of IOT-1583.
Change-Id: Ic4ec8a08d3934d698af493703de1966b78702dba
Signed-off-by: Sushil Yadav <sushil.ky@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20319
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
resource/src/InProcServerWrapper.cpp

index c2140c5..30ada5c 100644 (file)
@@ -603,17 +603,16 @@ namespace OC
         auto cLock = m_csdkLock.lock();
         OCStackResult result = OC_STACK_ERROR;
 
-        if (pResponse->getHeaderOptions().size() > MAX_HEADER_OPTIONS)
-        {
-            oclog() << "Error passed too many server header options.\n";
-            return OC_STACK_ERROR;
-        }
-
         if(!pResponse)
         {
             result = OC_STACK_MALFORMED_RESPONSE;
             throw OCException(OC::Exception::STR_NULL_RESPONSE, OC_STACK_MALFORMED_RESPONSE);
         }
+        else if (pResponse->getHeaderOptions().size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "Error passed too many server header options.\n";
+            return OC_STACK_ERROR;
+        }
         else
         {
             OCEntityHandlerResponse response;