From: Jihoon Kim Date: Tue, 17 Mar 2020 10:10:17 +0000 (+0900) Subject: Fix json parsing error due to trailing trash character X-Git-Tag: accepted/tizen/5.5/unified/20200318.130557~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5b9e3c2154ac5673199a866cd0a3b5db48569f8;p=platform%2Fcore%2Fuifw%2Fcapi-ui-sticker.git Fix json parsing error due to trailing trash character Change-Id: I3bce228b55b0ef16828783f15e3bc1c89af78dfa Signed-off-by: Jihoon Kim --- diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index f471b55..3f56506 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -406,7 +406,8 @@ void on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer, void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */ { - LOGI("received data: %s, len:%d", (char *)buffer, payload_length); + unsigned int buf_len = strlen((char *)buffer); + LOGI("received data: %s, len: %d, buffer len : %d", (char *)buffer, payload_length, buf_len); JsonParser *parser = json_parser_new(); GError *err_msg = NULL; @@ -415,7 +416,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in string msg_id; const char *json_msgid = NULL; - json_parser_load_from_data(parser, (char *)buffer, -1, &err_msg); + json_parser_load_from_data(parser, (char *)buffer, payload_length, &err_msg); if (err_msg) { LOGE("failed to load json file. error message: %s", err_msg->message); goto cleanup;