diff --git a/api/oc_ri.c b/api/oc_ri.c index 7ac882910f..814bcefe41 100644 --- a/api/oc_ri.c +++ b/api/oc_ri.c @@ -1388,29 +1388,31 @@ oc_ri_invoke_coap_entity_handler(const coap_packet_t *request, bool response_state_allocated = false; bool enable_realloc_rep = false; #endif /* OC_DYNAMIC_ALLOCATION */ - if (cur_resource && !bad_request && *ctx.response_state == NULL) { - OC_DBG("creating new block-wise response state"); - *ctx.response_state = oc_blockwise_alloc_response_buffer( - uri_path, uri_path_len, endpoint, method, OC_BLOCKWISE_SERVER, - OC_MIN_APP_DATA_SIZE); + if (cur_resource && !bad_request) { if (*ctx.response_state == NULL) { - OC_ERR("failure to alloc response state"); - bad_request = true; - } else { + OC_DBG("creating new block-wise response state"); + *ctx.response_state = oc_blockwise_alloc_response_buffer( + uri_path, uri_path_len, endpoint, method, OC_BLOCKWISE_SERVER, + OC_MIN_APP_DATA_SIZE); + if (*ctx.response_state == NULL) { + OC_ERR("failure to alloc response state"); + bad_request = true; + } else { #ifdef OC_DYNAMIC_ALLOCATION #ifdef OC_APP_DATA_BUFFER_POOL - if (!request_buffer->block) + if (!request_buffer->block) #endif /* OC_APP_DATA_BUFFER_POOL */ - { - response_state_allocated = true; - } + { + response_state_allocated = true; + } #endif /* OC_DYNAMIC_ALLOCATION */ - if (uri_query_len > 0) { - oc_new_string(&(*ctx.response_state)->uri_query, uri_query, - uri_query_len); + if (uri_query_len > 0) { + oc_new_string(&(*ctx.response_state)->uri_query, uri_query, + uri_query_len); + } + response_buffer.buffer = (*ctx.response_state)->buffer; + response_buffer.buffer_size = OC_MIN_APP_DATA_SIZE; } - response_buffer.buffer = (*ctx.response_state)->buffer; - response_buffer.buffer_size = OC_MIN_APP_DATA_SIZE; } } #else /* OC_BLOCK_WISE */ diff --git a/security/oc_obt.c b/security/oc_obt.c index 2700d3600c..45559cdbde 100644 --- a/security/oc_obt.c +++ b/security/oc_obt.c @@ -3567,15 +3567,15 @@ oc_obt_general_post(const oc_uuid_t *uuid, const char *query, const char *url, oc_rep_start_root_object(); for (int i = 0; i < array_size; i++) { if (strstr(payload_types[i], "bool") != NULL) { - int payload_int = strtol(payload_values[i], NULL, 10); - bool payload_bool = (payload_int ? true : false); + long payload_int = strtol(payload_values[i], NULL, 10); + bool payload_bool = (payload_int != 0 ? true : false); oc_rep_encode_text_string(&root_map, payload_properties[i], strlen(payload_properties[i])); oc_rep_encode_boolean(&root_map, payload_bool); } else if (strstr(payload_types[i], "int") != NULL) { - int payload_int = strtol(payload_values[i], NULL, 10); + long payload_int = strtol(payload_values[i], NULL, 10); oc_rep_encode_text_string(&root_map, payload_properties[i], strlen(payload_properties[i]));