Revise to check the return value of json_parser_new() 43/307043/1
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 4 Mar 2024 07:06:35 +0000 (16:06 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 4 Mar 2024 07:06:45 +0000 (16:06 +0900)
Error log for this situation is also added.

[Version] 0.4.48
[Issue Type] Improvement

Change-Id: I6035f5dd3ce04029b39f601a298c942ec97b62f4
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_internal.c
src/webrtc_private.c
test/webrtc_test_signaling.c

index aeddab2fc4971d21fa0cafef762e707a578df328..b4ccab3d7fe09a0bf8a946b2343afb1f751d0d57 100644 (file)
@@ -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
index 7e8ad38569de70c619797cec876555c4f5d635ad..208375a68c4656aa44b93d4eb4375912d5ae8cca 100644 (file)
@@ -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);
index 36e35221d7f58da5b92477c0b460b9cf26bdbb4d..0d92a0b915be23e515d679d51f205677fb6bf0c7 100644 (file)
@@ -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);
index eddaf3265317cf9851e65c2c6719aa047744559e..d6c1f8fe493b70f03a0bf50ac9ee9cb67d66560e 100644 (file)
@@ -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
+}