Fix dereferenced NULL 35/69735/3 accepted/tizen/common/20160520.170935 accepted/tizen/common/20160520.171027 accepted/tizen/ivi/20160520.002326 accepted/tizen/ivi/20160520.081047 accepted/tizen/mobile/20160520.002337 accepted/tizen/mobile/20160520.080909 accepted/tizen/tv/20160520.002258 accepted/tizen/tv/20160520.081001 accepted/tizen/wearable/20160520.002311 accepted/tizen/wearable/20160520.080927 submit/tizen/20160518.002620 submit/tizen/20160519.002157 submit/tizen/20160519.045032 submit/tizen/20160520.002716
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 16 May 2016 11:25:59 +0000 (20:25 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Wed, 18 May 2016 00:35:28 +0000 (09:35 +0900)
Change-Id: I6793dcb34244fd6f2d7dca7c293aa99e1ee32659
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/data-control-provider.c
src/data-control-sql-cursor.c

index 60c0f6c..80ca6d2 100755 (executable)
@@ -418,7 +418,7 @@ int __datacontrol_send_async(int sockfd, bundle *kb, datacontrol_request_type ty
        bundle_raw *kb_data = NULL;
        int ret = DATACONTROL_ERROR_NONE;
        int datalen = 0;
-       char *buf = NULL;
+       char *buf;
        int total_len = 0;
        unsigned int nb = 0;
 
@@ -432,6 +432,10 @@ int __datacontrol_send_async(int sockfd, bundle *kb, datacontrol_request_type ty
 
        /* encoded bundle + encoded bundle len */
        buf = (char *)calloc(datalen + 4, sizeof(char));
+       if (buf == NULL) {
+               LOGE("buf calloc error");
+               return DATACONTROL_ERROR_OUT_OF_MEMORY;
+       }
        memcpy(buf, &datalen, sizeof(datalen));
        memcpy(buf + sizeof(datalen), kb_data, datalen);
 
@@ -450,8 +454,7 @@ int __datacontrol_send_async(int sockfd, bundle *kb, datacontrol_request_type ty
                ret = __send_get_value_result(sockfd, kb, data);
 
 out:
-       if (buf)
-               free(buf);
+       free(buf);
        bundle_free_encoded_rawdata(&kb_data);
 
        return ret;
index fdd4516..fb5cc4a 100755 (executable)
@@ -587,18 +587,19 @@ int datacontrol_sql_remove_cursor(resultset_cursor *cursor)
 {
        int ret;
 
-       close(cursor->resultset_fd);
-
-       ret = remove(cursor->resultset_path);
-       if (ret == -1)
-               LOGE("unable to remove map query result file: %d", ret);
+       if (cursor == NULL)
+               return DATACONTROL_ERROR_INVALID_PARAMETER;
 
+       close(cursor->resultset_fd);
+       if (cursor->resultset_path) {
+               ret = remove(cursor->resultset_path);
+               if (ret == -1)
+                       LOGE("unable to remove map query result file: %d", ret);
+               free(cursor->resultset_path);
+       }
        if (cursor->row_offset_list)
                free(cursor->row_offset_list);
-       if (cursor->resultset_path)
-               free(cursor->resultset_path);
-       if (cursor)
-               free(cursor);
+       free(cursor);
 
        return DATACONTROL_ERROR_NONE;
 }