Free before return 52/237152/1 accepted/tizen/5.5/unified/20200629.130308 submit/tizen_5.5/20200629.013201
authorCheoleun Moon <chleun.moon@samsung.com>
Thu, 25 Jun 2020 09:42:14 +0000 (18:42 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Thu, 25 Jun 2020 09:42:18 +0000 (18:42 +0900)
Change-Id: I951213a634605c561d9061c45134c6d7ef924d67

src/stc-manager-util.c
src/stc-pcap.c
src/stc-restriction.c
src/stc-statistics.c

index 1f25927..3e77610 100755 (executable)
@@ -182,4 +182,5 @@ void stc_util_initialize_config(void)
        }
 
        __save_key_file(keyfile, path);
+       g_key_file_free(keyfile);
 }
index 3faa7ec..29f5037 100755 (executable)
@@ -106,6 +106,7 @@ gboolean handle_pcap_start(StcPcap *object,
        if (__validate_pcap(&pcap) == FALSE) {
                STC_PCAP_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
                                                 STC_ERROR_INVALID_PARAMETER);
+               g_free(pcap.ifname);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
@@ -113,11 +114,13 @@ gboolean handle_pcap_start(StcPcap *object,
        ret = stc_plugin_pcap_register_loop(pcap.ifname, pcap.nflog_group);
        if (ret != STC_ERROR_NONE) {
                STC_PCAP_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE
+               g_free(pcap.ifname);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
 
        STC_DBUS_REPLY_ERROR_NONE(invocation);
+       g_free(pcap.ifname);
        __STC_LOG_FUNC_EXIT__;
        return TRUE;
 }
@@ -147,6 +150,7 @@ gboolean handle_pcap_stop(StcPcap *object,
        if (__validate_pcap(&pcap) == FALSE) {
                STC_PCAP_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
                                                 STC_ERROR_INVALID_PARAMETER);
+               g_free(pcap.ifname);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
@@ -154,11 +158,13 @@ gboolean handle_pcap_stop(StcPcap *object,
        ret = stc_plugin_pcap_unregister_loop(pcap.ifname, pcap.nflog_group);
        if (ret != STC_ERROR_NONE) {
                STC_PCAP_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE
+               g_free(pcap.ifname);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
 
        STC_DBUS_REPLY_ERROR_NONE(invocation);
+       g_free(pcap.ifname);
        __STC_LOG_FUNC_EXIT__;
        return TRUE;
 }
index d47aaf0..47bfee8 100755 (executable)
@@ -259,6 +259,14 @@ static void __stc_extract_restriction_rule(const char *key, GVariant *value,
        }
 }
 
+static void __stc_free_restriction_rule_members(table_restrictions_info *rule)
+{
+       FREE(rule->app_id);
+       FREE(rule->ifname);
+       FREE(rule->subscriber_id);
+       FREE(rule->mac);
+}
+
 gboolean handle_restriction_set(StcRestriction *object,
                                GDBusMethodInvocation *invocation,
                                GVariant *parameters,
@@ -285,6 +293,7 @@ gboolean handle_restriction_set(StcRestriction *object,
        if (__validate_rstn_rule(&rule) == FALSE) {
                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
                                                 STC_ERROR_INVALID_PARAMETER);
+               __stc_free_restriction_rule_members(&rule);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
@@ -293,12 +302,14 @@ gboolean handle_restriction_set(StcRestriction *object,
        if (ret != STC_ERROR_NONE) {
                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
                                                 STC_ERROR_DB_FAILED);
+               __stc_free_restriction_rule_members(&rule);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
 
        stc_plugin_monitor_add_rstn(&rule);
        STC_DBUS_REPLY_ERROR_NONE(invocation);
+       __stc_free_restriction_rule_members(&rule);
        __STC_LOG_FUNC_EXIT__;
        return TRUE;
 }
@@ -329,6 +340,7 @@ gboolean handle_restriction_unset(StcRestriction *object,
        if (__validate_rstn_rule(&rule) == FALSE) {
                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
                                                 STC_ERROR_INVALID_PARAMETER);
+               __stc_free_restriction_rule_members(&rule);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
@@ -338,12 +350,14 @@ gboolean handle_restriction_unset(StcRestriction *object,
        if (ret != STC_ERROR_NONE) {
                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, //LCOV_EXCL_LINE
                                                 STC_ERROR_DB_FAILED);
+               __stc_free_restriction_rule_members(&rule);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE;
        }
 
        stc_plugin_monitor_remove_rstn(&rule);
        STC_DBUS_REPLY_ERROR_NONE(invocation);
+       __stc_free_restriction_rule_members(&rule);
        __STC_LOG_FUNC_EXIT__;
        return TRUE;
 }
@@ -376,6 +390,7 @@ gboolean handle_restriction_set_list(StcRestriction *object,
                                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE
                                g_variant_iter_free(iter_row);
                                g_variant_iter_free(iter);
+                               __stc_free_restriction_rule_members(&rule);
                                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                                return TRUE;
                        }
@@ -385,11 +400,13 @@ gboolean handle_restriction_set_list(StcRestriction *object,
                                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE
                                g_variant_iter_free(iter_row);
                                g_variant_iter_free(iter);
+                               __stc_free_restriction_rule_members(&rule);
                                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                                return TRUE;
                        }
                }
 
+               __stc_free_restriction_rule_members(&rule);
                g_variant_iter_free(iter_row);
        }
        g_variant_iter_free(iter);
@@ -428,6 +445,7 @@ gboolean handle_restriction_unset_list(StcRestriction *object,
                                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE
                                g_variant_iter_free(iter_row);
                                g_variant_iter_free(iter);
+                               __stc_free_restriction_rule_members(&rule);
                                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                                return TRUE;
                        }
@@ -437,11 +455,13 @@ gboolean handle_restriction_unset_list(StcRestriction *object,
                                STC_RESTRICTION_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE
                                g_variant_iter_free(iter_row);
                                g_variant_iter_free(iter);
+                               __stc_free_restriction_rule_members(&rule);
                                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                                return TRUE;
                        }
                }
 
+               __stc_free_restriction_rule_members(&rule);
                g_variant_iter_free(iter_row);
        }
        g_variant_iter_free(iter);
index a0b5a07..feee566 100755 (executable)
@@ -360,6 +360,7 @@ gboolean handle_statistics_get(StcStatistics *object,
        if (ret < STC_ERROR_NONE) {
                g_variant_builder_unref(builder); //LCOV_EXCL_LINE
                STC_STATISTICS_DBUS_REPLY_ERROR(invocation, ret); //LCOV_EXCL_LINE
+               g_free(rule.app_id);
                __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
                return TRUE; //LCOV_EXCL_LINE
        }
@@ -370,6 +371,7 @@ gboolean handle_statistics_get(StcStatistics *object,
        DEBUG_GDBUS_VARIANT("Return parameters: ", return_parameters);
        STC_DBUS_REPLY(invocation, return_parameters);
 
+       g_free(rule.app_id);
        __STC_LOG_FUNC_EXIT__;
        return TRUE;
 }