Imported Upstream version 1.0.1
[platform/upstream/iotivity.git] / resource / csdk / connectivity / common / src / caremotehandler.c
index a39b7d4..1315dae 100644 (file)
@@ -55,6 +55,20 @@ CARequestInfo_t *CACloneRequestInfo(const CARequestInfo_t *rep)
         return NULL;
     }
 
+    // check the method type of request info.
+    // Keep this check in sync with CAMethod_t
+    switch (rep->method)
+    {
+        case CA_GET:
+        case CA_POST:
+        case CA_PUT:
+        case CA_DELETE:
+            break;
+        default:
+            OIC_LOG_V(ERROR, TAG, "Method %u is invalid", rep->method);
+            return NULL;
+    }
+
     // allocate the request info structure.
     CARequestInfo_t *clone = (CARequestInfo_t *) OICMalloc(sizeof(CARequestInfo_t));
     if (!clone)