From 3c2f64801a72a114dab5e53b1e2a823a59b19cfa Mon Sep 17 00:00:00 2001 From: Joseph Morrow Date: Thu, 30 Jul 2015 11:57:01 -0700 Subject: [PATCH] Added null checks post cbor processing. This allows requests with null parameters to still operate. This fixes IOT-632. Change-Id: I6b7b1a48e1d50d34268e1f0fface38b5fd59cb02 Signed-off-by: Joseph Morrow Reviewed-on: https://gerrit.iotivity.org/gerrit/1993 Reviewed-by: Tim Kourt Tested-by: jenkins-iotivity Reviewed-by: Erich Keane --- resource/include/OCRepresentation.h | 2 ++ resource/src/OCRepresentation.cpp | 4 ++++ resource/src/OCResourceRequest.cpp | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resource/include/OCRepresentation.h b/resource/include/OCRepresentation.h index 7856613..b89b9fb 100644 --- a/resource/include/OCRepresentation.h +++ b/resource/include/OCRepresentation.h @@ -118,6 +118,8 @@ namespace OC void setChildren(const std::vector& children); + void setUri(const char* uri); + void setUri(const std::string& uri); std::string getUri() const; diff --git a/resource/src/OCRepresentation.cpp b/resource/src/OCRepresentation.cpp index d439bbe..998bdbe 100644 --- a/resource/src/OCRepresentation.cpp +++ b/resource/src/OCRepresentation.cpp @@ -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) { diff --git a/resource/src/OCResourceRequest.cpp b/resource/src/OCResourceRequest.cpp index e5850fb..d600017 100644 --- a/resource/src/OCResourceRequest.cpp +++ b/resource/src/OCResourceRequest.cpp @@ -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; -- 2.7.4