[Internal:Prevent] Fixed for prevent defect. (4EA)
authorsanghyuk Ko <sanghyuk.ko@samsung.com>
Fri, 16 Aug 2013 09:58:24 +0000 (18:58 +0900)
committersanghyuk Ko <sanghyuk.ko@samsung.com>
Fri, 16 Aug 2013 09:58:24 +0000 (18:58 +0900)
[Problem]
-
[Cause]
-
[Solution]
- Fixed for prevent defect. (4EA - CID 19564,19432,24599,24784)

Change-Id: I18cb5eda666a7601d76d99945c727d873810f7f7

src/agent/framework/san-parser/pm_sanparser.c
src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c
src/agent/service-adapter/sa_command.c
src/agent/service-adapter/sa_common_interface.c

index bbb21e7..1b10e9b 100755 (executable)
@@ -221,6 +221,7 @@ san_package_s *san_package_11_parser(const char *msg_body, unsigned int msg_size
        }
 
        WBXMLTree *wbxml_tree = NULL;
+       WBXMLList *alertnode_list = NULL;
        WBXMLError wbxml_err = wbxml_tree_from_wbxml((unsigned char *)msg_body, msg_size, WBXML_LANG_UNKNOWN, WBXML_CHARSET_UNKNOWN, &wbxml_tree);
 
        if (wbxml_err != WBXML_OK) {
@@ -381,7 +382,7 @@ san_package_s *san_package_11_parser(const char *msg_body, unsigned int msg_size
                goto error;
        }
 
-       WBXMLList *alertnode_list = wbxml_tree_node_get_all_children(syncbody_node);
+       alertnode_list = wbxml_tree_node_get_all_children(syncbody_node);
        unsigned int alertnode_list_len = wbxml_list_len(alertnode_list);
 
        child_node = (WBXMLTreeNode *) wbxml_list_get(alertnode_list, alertnode_list_len - 1);
@@ -391,6 +392,7 @@ san_package_s *san_package_11_parser(const char *msg_body, unsigned int msg_size
 
        if (san->cnt_sync_alerts == 0) {
                /* If number of sync alerts equals 0, should sync all data store in the client */
+               wbxml_list_destroy(alertnode_list, NULL);
                return san;
        } else {
                san->sync_alerts = (san_sync_alert_s *) calloc(san->cnt_sync_alerts, sizeof(san_sync_alert_s));
@@ -492,6 +494,7 @@ san_package_s *san_package_11_parser(const char *msg_body, unsigned int msg_size
                }
        }
 
+       wbxml_list_destroy(alertnode_list, NULL);
        wbxml_tree_destroy(wbxml_tree);
 
        _EXTERN_FUNC_EXIT;
@@ -499,6 +502,9 @@ san_package_s *san_package_11_parser(const char *msg_body, unsigned int msg_size
 
  error:
 
+       wbxml_list_destroy(alertnode_list, NULL);
+       wbxml_tree_destroy(wbxml_tree);
+
        sanPackageParserFree(san);
 
        _EXTERN_FUNC_EXIT;
index 04cc566..fe5bd2c 100755 (executable)
@@ -3307,9 +3307,6 @@ static sync_agent_pb_error_e _oma_ds_binder_devinf_reverse_converter_function(sy
                                                                        if (pDevInfCtCap != NULL)
                                                                                free(pDevInfCtCap);
 
-                                                                       if (devinf_content_type != NULL)
-                                                                               free(devinf_content_type);
-
                                                                        goto return_part;
                                                                }
                                                        }
index 7a65503..451b25a 100755 (executable)
@@ -742,6 +742,9 @@ sa_error_type_e create_new_status_location(session_s * session, oma_status_type_
        _EXTERN_FUNC_ENTER;
        _DEBUG_INFO("start Errortype %d", data);
 
+       retvm_if(session == NULL, SA_INTERNAL_ERROR, "session is NULL!!");
+       retvm_if(command == NULL, SA_INTERNAL_ERROR, "command is NULL!!");
+
        sa_error_type_e errorType = SA_INTERNAL_OK;
 
        errorType = create_status(data, session->cmd_id, session->last_recieved_msg_id, command->cmd_id, source_ref, target_ref, type, status);
@@ -761,6 +764,9 @@ sa_error_type_e create_new_status(session_s * session, oma_status_type_e data, c
        _EXTERN_FUNC_ENTER;
        _DEBUG_INFO("start Errortype %d", data);
 
+       retvm_if(session == NULL, SA_INTERNAL_ERROR, "session is NULL!!");
+       retvm_if(command == NULL, SA_INTERNAL_ERROR, "command is NULL!!");
+
        sa_error_type_e errorType = SA_INTERNAL_OK;
 
        errorType = create_status(data, session->cmd_id, session->last_recieved_msg_id, command->cmd_id, command->source, command->target, type, status);
index bc5a6ac..0847219 100755 (executable)
@@ -1838,16 +1838,30 @@ static sa_error_type_e _generate_autoconfigure_msg(char *id, char *pwd, char *ta
        return errorType;
 
  error:
-       if (pSyncHdr != NULL)
+       if (pSyncHdr != NULL) {
                free_sync_hdr(pSyncHdr);
-       if (pCred != NULL)
+               pSyncHdr = NULL;
+       }
+       if (pCred != NULL) {
                free_cred(pCred);
-       if (credData != NULL)
+               pCred = NULL;
+       }
+       if (credData != NULL) {
                free(credData);
-       if (commands != NULL)
+               credData = NULL;
+       }
+       if (pGetCommand != NULL) {
+               free_command(pGetCommand);
+               pGetCommand = NULL;
+       }
+       if (commands != NULL) {
                free_commands(commands);
-       if (syncml != NULL)
+               commands = NULL;
+       }
+       if (syncml != NULL) {
                free(syncml);
+               syncml = NULL;
+       }
 
        _INNER_FUNC_EXIT;
        return errorType;