Fix bug (Failed caching with list) 37/70637/5
authorsung.goo.kim <sung.goo.kim@samsung.com>
Fri, 20 May 2016 02:36:25 +0000 (11:36 +0900)
committerSunggoo Kim <sung.goo.kim@samsung.com>
Mon, 23 May 2016 06:47:29 +0000 (23:47 -0700)
Change-Id: I2d757a021aa46784b742eba4ae541372903034c6

lib/icl-ioty-types.c
lib/icl-ioty.c

index 811ad75ab4bb896359c083664df1a7e1eccfba14..c4a5d70ecadaf516b0d0f4029f64475ba0b7e056 100644 (file)
@@ -774,11 +774,11 @@ static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload,
                        ERR("calloc() Fail(%d)", errno);
                        return IOTCON_ERROR_OUT_OF_MEMORY;
                }
-               for (node = list->list, i = 0; node; node = node->next, i++) {
+               for (node = list->list, i = 0; node; node = node->next, i++)
                        str_arr[i] = ((icl_basic_s*)node->data)->val.s;
-                       ((icl_basic_s*)node->data)->val.s = NULL;
-               }
-               OCRepPayloadSetStringArrayAsOwner(payload, key, str_arr, list->dimensions);
+
+               OCRepPayloadSetStringArray(payload, key, (const char **)str_arr, list->dimensions);
+               free(str_arr);
                break;
        case OCREP_PROP_BYTE_STRING:
                byte_arr = calloc(len, sizeof(OCByteString));
@@ -791,6 +791,7 @@ static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload,
                        byte_arr[i].len = ((icl_val_byte_str_s*)node->data)->len;
                }
                OCRepPayloadSetByteStringArray(payload, key, byte_arr, list->dimensions);
+               free(byte_arr);
                break;
        case OCREP_PROP_OBJECT:
                state_arr = calloc(len, sizeof(struct OCRepPayload *));
@@ -871,7 +872,7 @@ static int _icl_ioty_state_list_to_value_list(iotcon_list_h list,
                break;
        case IOTCON_TYPE_LIST:
                for (c = list->list; c; c = c->next) {
-                       ret = _icl_ioty_state_list_to_value_list(c->data, value_list, depth + 1);
+                       ret = _icl_ioty_state_list_to_value_list(((icl_val_list_s *)c->data)->list, value_list, depth + 1);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("_icl_ioty_state_list_to_value_list() Fail(%d)", ret);
                                return ret;
index 6a54536c4973e8a9dff7df91293062334782476a..e19dcd91ce5869f9513afb15be0a2f0ce344f1d5 100644 (file)
@@ -1156,7 +1156,9 @@ static void _icl_ioty_caching_get_cb(iotcon_remote_resource_h resource,
                resource->cached_repr = repr;
                if (response)
                        response->repr = NULL;
-               cb_container->cb(resource, resource->cached_repr, cb_container->user_data);
+
+               if (cb_container->cb)
+                       cb_container->cb(resource, resource->cached_repr, cb_container->user_data);
        }
 }