diff --git a/components/connectivity/qcloud-iot-hub-sdk-3.1.2/port/TencentOS_tiny/HAL_Device_tencentos_tiny.c b/components/connectivity/qcloud-iot-hub-sdk-3.1.2/port/TencentOS_tiny/HAL_Device_tencentos_tiny.c index 4646e8d1..c3c32fee 100644 --- a/components/connectivity/qcloud-iot-hub-sdk-3.1.2/port/TencentOS_tiny/HAL_Device_tencentos_tiny.c +++ b/components/connectivity/qcloud-iot-hub-sdk-3.1.2/port/TencentOS_tiny/HAL_Device_tencentos_tiny.c @@ -143,11 +143,13 @@ int HAL_GetGwDevInfo(void *pgwDeviceInfo) //only one sub-device is supported now gwDevInfo->sub_dev_num = 1; gwDevInfo->sub_dev_info = (DeviceInfo *)HAL_Malloc(sizeof(DeviceInfo)*(gwDevInfo->sub_dev_num)); - memset((char *)gwDevInfo->sub_dev_info, '\0', sizeof(DeviceInfo)); - //copy sub dev info - ret = device_info_copy(gwDevInfo->sub_dev_info->product_id, sg_sub_device_product_id, MAX_SIZE_OF_PRODUCT_ID); - ret |= device_info_copy(gwDevInfo->sub_dev_info->device_name, sg_sub_device_name, MAX_SIZE_OF_DEVICE_NAME); - + if(gwDevInfo->sub_dev_info) + { + memset((char *)gwDevInfo->sub_dev_info, '\0', sizeof(DeviceInfo)); + //copy sub dev info + ret = device_info_copy(gwDevInfo->sub_dev_info->product_id, sg_sub_device_product_id, MAX_SIZE_OF_PRODUCT_ID); + ret |= device_info_copy(gwDevInfo->sub_dev_info->device_name, sg_sub_device_name, MAX_SIZE_OF_DEVICE_NAME); + } #else Log_e("HAL_GetDevInfo not implement yet"); ret = QCLOUD_ERR_DEV_INFO; diff --git a/examples/tencent_cloud_sdk_data_template/light_data_template_sample.c b/examples/tencent_cloud_sdk_data_template/light_data_template_sample.c index 5015809b..82dad86d 100644 --- a/examples/tencent_cloud_sdk_data_template/light_data_template_sample.c +++ b/examples/tencent_cloud_sdk_data_template/light_data_template_sample.c @@ -245,6 +245,10 @@ static qcloud_err_t property_update(const char *json_doc, shadow_dev_property_t /* convert const char * to char * */ json_doc_mutable = osal_malloc(strlen(json_doc)); + if(!json_doc_mutable) + { + return QCLOUD_ERR_FAILURE; + } QCLOUD_FUNC_EXIT_RC_IF(json_doc_mutable, NULL, QCLOUD_ERR_FAILURE); strcpy(json_doc_mutable, json_doc);