fix memory leak 96/78596/7
authorJeesun Kim <iamjs.kim@samsung.com>
Wed, 6 Jul 2016 07:37:15 +0000 (16:37 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Tue, 26 Jul 2016 07:39:10 +0000 (16:39 +0900)
Change-Id: I7da2d6ec5c13809f1acadaf88b77cd627044a62a

client/cal_client_dbus.c
common/cal_vcalendar_parse.c
common/dbus/cal_dbus_helper.c
server/cal_server_dbus.c

index 47445b3..7112788 100644 (file)
@@ -351,6 +351,7 @@ int cal_dbus_delete_record(calendar_h handle, const char *view_uri, int id)
 
        RETV_IF(NULL == handle, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(id < 0, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cal_dbus_object, CALENDAR_ERROR_IPC);
 
        CAL_LIMIT_ACCESS_FRONT(view_uri);
@@ -384,6 +385,7 @@ int cal_dbus_replace_record(calendar_h handle, calendar_record_h record, int id)
 
        RETV_IF(NULL == handle, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(id < 0, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cal_dbus_object, CALENDAR_ERROR_IPC);
 
        CAL_LIMIT_ACCESS_FRONT(((cal_record_s *)record)->view_uri);
@@ -569,6 +571,7 @@ int cal_dbus_get_record(calendar_h handle, const char *view_uri, int id,
 
        RETV_IF(NULL == handle, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == out_record, CALENDAR_ERROR_INVALID_PARAMETER);
+       RETV_IF(id < 0, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cal_dbus_object, CALENDAR_ERROR_IPC);
 
        DBG("uri[%s]", view_uri);
index 079ec57..7eab265 100644 (file)
@@ -805,7 +805,12 @@ static char* __decode_datetime(char *p, struct user_data *ud)
        /* param start */
        char **s = NULL;
        s = g_strsplit(p, ";", -1);
-       RETVM_IF(NULL == s, p + strlen(p) - len_param, "g_strsplit() Fail");
+       if (NULL == s) {
+               /* LCOV_EXCL_START */
+               ERR("g_strsplit() Fail");
+               return NULL;
+               /* LCOV_EXCL_STOP */
+       }
 
        int count_param = g_strv_length(s);
        DBG("count_param(%d)", count_param);
index bdd3270..ab835bb 100644 (file)
@@ -30,7 +30,7 @@
 
 #define CAL_DBUS_SET_STRING(x) (x) ? x : ""
 #define CAL_DBUS_GET_STRING(x) do { \
-       x = (NULL != x && '\0' != *x) ? strdup(x) : NULL; \
+       x = (NULL != x) ? strdup(x) : NULL; \
 } while (0)
 
 GVariant* cal_dbus_utils_null_to_gvariant(void)
@@ -1168,6 +1168,7 @@ static void _get_attribute_filter(GVariantIter *iter_filter, cal_filter_type_e f
        switch (filter_type) {
        case CAL_FILTER_STR:
                g_variant_get(arg_value, "&s", &filter->value.s);
+               CAL_DBUS_GET_STRING(filter->value.s);
                break;
        case CAL_FILTER_INT:
                g_variant_get(arg_value, "i", &filter->value.i);
@@ -1197,6 +1198,7 @@ static int _get_composite_filter(GVariantIter *iter_filter, cal_composite_filter
        GVariant *arg_value = NULL;
        g_variant_iter_loop(iter_filter, "v", &arg_value);
        g_variant_get(arg_value, "&s", &filter->view_uri);
+       CAL_DBUS_GET_STRING(filter->view_uri);
 
        int filter_count = 0;
        g_variant_iter_loop(iter_filter, "v", &arg_value);
@@ -1305,9 +1307,13 @@ int cal_dbus_utils_gvariant_to_query(GVariant *arg_query, calendar_query_h *out_
 
        if (has_filter)
                _gvariant_to_filter(arg_filter, q);
+       else
+               q->filter = NULL;
 
        if (count_projection)
                _gvariant_to_projection(count_projection, arg_projection, q);
+       else
+               q->projection = NULL;
 
        q->sort_property_id = property_id;
        q->properties = (cal_property_info_s *)cal_view_get_property_info(view_uri,
index f09e488..965a71c 100644 (file)
@@ -345,6 +345,7 @@ static gboolean _handle_get_records_with_query(calDbus *object, GDBusMethodInvoc
 
        calendar_list_h list = NULL;
        ret = cal_db_get_records_with_query(query, offset, limit, &list);
+       calendar_query_destroy(query);
 
        GVariant *arg_list = cal_dbus_utils_list_to_gvariant(list);
        cal_dbus_complete_get_records_with_query(object, invocation, arg_list, ret);
@@ -377,6 +378,8 @@ static gboolean _handle_get_count_with_query(calDbus *object, GDBusMethodInvocat
 
        int count = 0;
        ret = cal_db_get_count_with_query(query, &count);
+       calendar_query_destroy(query);
+
        cal_dbus_complete_get_count_with_query(object, invocation, count, ret);
 
        cal_server_ondemand_start();