Added null checks post cbor processing.
authorJoseph Morrow <joseph.l.morrow@intel.com>
Thu, 30 Jul 2015 18:57:01 +0000 (11:57 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 30 Jul 2015 19:24:59 +0000 (19:24 +0000)
This allows requests with null parameters to still operate.

This fixes IOT-632.

Change-Id: I6b7b1a48e1d50d34268e1f0fface38b5fd59cb02
Signed-off-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1993
Reviewed-by: Tim Kourt <tim.a.kourt@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/include/OCRepresentation.h
resource/src/OCRepresentation.cpp
resource/src/OCResourceRequest.cpp

index 7856613..b89b9fb 100644 (file)
@@ -118,6 +118,8 @@ namespace OC
 
             void setChildren(const std::vector<OCRepresentation>& children);
 
+            void setUri(const char* uri);
+
             void setUri(const std::string& uri);
 
             std::string getUri() const;
index d439bbe..998bdbe 100644 (file)
@@ -619,6 +619,10 @@ namespace OC
     {
         m_children = children;
     }
+    void OCRepresentation::setUri(const char* uri)
+    {
+        m_uri = uri ? uri : "";
+    }
 
     void OCRepresentation::setUri(const std::string& uri)
     {
index e5850fb..d600017 100644 (file)
@@ -30,7 +30,11 @@ void OCResourceRequest::setPayload(OCPayload* payload)
 {
     MessageContainer info;
 
-    if(payload == nullptr || payload->type != PAYLOAD_TYPE_REPRESENTATION)
+    if(payload == nullptr)
+    {
+        return;
+    }
+    if(payload->type != PAYLOAD_TYPE_REPRESENTATION)
     {
         throw std::logic_error("Wrong payload type");
         return;