Copy all items of CBOR string array
authorSakthivel Samidurai <sakthivel.samidurai@intel.com>
Thu, 30 Jul 2015 14:21:24 +0000 (07:21 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 30 Jul 2015 16:14:46 +0000 (16:14 +0000)
CBOR String array is coping only the first item.
Fix OCREP_PROP_STRING for string array to copy all items by
calling cbor_value_advance.

Change-Id: I1ea80e94cf21f746188af81dd946c474d8b00ba4
Signed-off-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1990
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/src/ocpayloadparse.c

index 4959c0b..34e940c 100644 (file)
@@ -604,9 +604,9 @@ static bool OCParseArray(OCRepPayload* out, const char* name, CborValue* contain
             arr = (char**)OICMalloc(dimTotal * sizeof(char*));
             for(size_t i = 0; i < dimTotal && !err; ++i)
             {
-                 err = err || cbor_value_dup_text_string(&insideArray, &tempStr,
-                        &len, NULL);
-                ((char**)arr)[i] = tempStr;
+                err = err || cbor_value_dup_text_string(&insideArray, &tempStr, &len, NULL);
+                ((char**) arr)[i] = tempStr;
+                err = err || cbor_value_advance(&insideArray);
             }
             if(!err &&
                 OCRepPayloadSetStringArrayAsOwner(out, name, (char**)arr, dimensions))