Use epc_object_unref instead of _destroy consistently 59/318859/1 accepted/tizen_unified accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen accepted/tizen/unified/20250131.095236 accepted/tizen/unified/x/20250212.043811 accepted/tizen/unified/x/asan/20250211.003405
authorMateusz Majewski <m.majewski2@samsung.com>
Tue, 28 Jan 2025 07:16:44 +0000 (08:16 +0100)
committerMateusz Majewski <m.majewski2@samsung.com>
Tue, 28 Jan 2025 07:23:18 +0000 (08:23 +0100)
The epc_object has built-in reference counting. The _destroy function
only erases internal data of the object and seems to be intended in
cases where an object is statically allocated, ignoring the reference
counter. However, this does not seem to be actually used anywhere, and
instead all _destroy instances we found were memory leaks, so we use
_unref there.

At the same time, we don't want to remove _destroy (or corresponding
_init) completely, as it seems to be a part of the public activationd
interface, and removing it could turn out to be a breaking change.

Change-Id: I230d8a48223999eda778e5d301de013cca92c012

src/action/action_executor.c
src/event_types/dbus_signal_event.c
src/listeners/dbus.c

index 9d0a15e8dcb965be9d903bc801dc0c044ad0f15c..87065b2feccfed1eb792a6568e4025d8a8216e49 100644 (file)
@@ -109,7 +109,7 @@ static int action_executor_callback(sd_event_source *s, int fd,
        ret = epc_event_create(ACTION_EXECUTED_EVENT_ID, &ae_data, &ev);
        if (ret < 0) {
                log_error("Unable to create action executed event");
-               epc_object_destroy(ae_data.action_log);
+               epc_object_unref(ae_data.action_log);
                goto out;
        }
 
index 29a22c3619c4ee1a058c86987167299b15e62ffa..a2cf5a51460e26003fb2fe9861ec48e26dcb6a3f 100644 (file)
@@ -143,7 +143,7 @@ static void dbus_signal_event_release(struct epc_event *ev)
        free(ds_ev->path_namespace);
        free(ds_ev->destination);
        if (ds_ev->match_params)
-               epc_object_destroy(ds_ev->match_params);
+               epc_object_unref(ds_ev->match_params);
 
        if (ds_ev->signal_params)
                g_variant_unref(ds_ev->signal_params);
index 8da04d822adb0e8375f7d58eedf2f8b0e9e9f486..8327a8b29e4aea9fadd5956cbd49d6c7dca1469d 100644 (file)
@@ -218,7 +218,7 @@ finish:
        free(ds_ev_data.path_namespace);
        free(ds_ev_data.destination);
        if (ds_ev_data.match_params)
-               epc_object_destroy(ds_ev_data.match_params);
+               epc_object_unref(ds_ev_data.match_params);
 }
 
 static void signal_cleanup(struct dbus_signal *s)