From: Sangchul Lee Date: Mon, 4 Mar 2024 07:06:35 +0000 (+0900) Subject: Revise to check the return value of json_parser_new() X-Git-Tag: accepted/tizen/unified/20240327.141705~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db82731d3e982748b1d37a2f4144c82b46409602;p=platform%2Fcore%2Fapi%2Fwebrtc.git Revise to check the return value of json_parser_new() Error log for this situation is also added. [Version] 0.4.48 [Issue Type] Improvement Change-Id: I6035f5dd3ce04029b39f601a298c942ec97b62f4 Signed-off-by: Sangchul Lee (cherry picked from commit d4070245a3b7d0563dee0349f8d6e7da4c30e5fb) --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index aeddab2f..b4ccab3d 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.4.47 +Version: 0.4.48 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 7e8ad385..208375a6 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -370,9 +370,10 @@ int webrtc_util_strip_description(const char *origin_description, char **descrip RET_VAL_IF(origin_description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "origin_description is NULL"); RET_VAL_IF(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL"); - parser = json_parser_new(); - if (!JSON_IS_PARSER(parser)) + if (!(parser = json_parser_new())) { + LOG_ERROR("failed to json_parser_new()"); return WEBRTC_ERROR_INVALID_OPERATION; + } if (!json_parser_load_from_data(parser, origin_description, -1, NULL)) { LOG_ERROR("unknown description: %s", origin_description); diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 36e35221..0d92a0b9 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -1964,9 +1964,10 @@ static int __get_sdp_from_description(const char *description, gchar **sdp, gcha RET_VAL_IF(sdp == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "sdp is NULL"); RET_VAL_IF(type == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "type is NULL"); - parser = json_parser_new(); - if (!JSON_IS_PARSER(parser)) + if (!(parser = json_parser_new())) { + LOG_ERROR("failed to json_parser_new()"); return WEBRTC_ERROR_INVALID_OPERATION; + } if (!json_parser_load_from_data(parser, description, -1, NULL)) { LOG_ERROR("unknown description: %s", description); @@ -2079,9 +2080,10 @@ static int __get_ice_candidate_from_message(const char *ice_message, gchar **can RET_VAL_IF(candidate == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "candidate is NULL"); RET_VAL_IF(mlineindex == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "mlineindex is NULL"); - parser = json_parser_new(); - if (!JSON_IS_PARSER(parser)) + if (!(parser = json_parser_new())) { + LOG_ERROR("failed to json_parser_new()"); return WEBRTC_ERROR_INVALID_OPERATION; + } if (!json_parser_load_from_data(parser, ice_message, -1, NULL)) { LOG_ERROR("unknown message: %s", ice_message); diff --git a/test/webrtc_test_signaling.c b/test/webrtc_test_signaling.c index eddaf326..d6c1f8fe 100644 --- a/test/webrtc_test_signaling.c +++ b/test/webrtc_test_signaling.c @@ -219,7 +219,10 @@ static void __handle_json_structured_message(connection_s *conn, const gchar *te RET_IF(!conn, "conn is NULL"); RET_IF(!text, "text is NULL"); - parser = json_parser_new(); + if (!(parser = json_parser_new())) { + g_printerr("failed to json_parser_new()\n"); + return; + } if (!json_parser_load_from_data(parser, text, -1, NULL)) { g_printerr("unknown message [%s]\n", text); @@ -667,4 +670,4 @@ void _websocket_send_text_for_room(connection_s *conn, int remote_peer_id, const message_for_room = g_strdup_printf ("ROOM_PEER_MSG %d %s", remote_peer_id, message); soup_websocket_connection_send_text(get_appdata()->signaling_server.public.ws_conn, message_for_room); g_free(message_for_room); -} \ No newline at end of file +}