Fix crash when uninstalling snap
Issue:
app_data
is an argument to both the actual and progress callbacks of snapd_client_remove2_async ()
. In this case, using g_steal_pointer
on one of them will render the other one to be NULL, causing the crash.
Fix:
Follow the same convention used in install operation.
Additional details:
(gdb) bt
#0 0x00007fdb54b8f215 in uninstall_progress_cb (client=0x55b254688280 [SnapdClient], change=0x55b2506448a0 [SnapdChange], deprecated=0x55b253357980, user_data=0x0) at ../plugins/snap/gs-plugin-snap.c:2375
#1 0x00007fdb54b1a552 in update_changes (self=0x55b254688280 [SnapdClient], change=0x55b2506448a0 [SnapdChange], data=0x55b254c1c150) at ../snapd-glib/snapd-client.c:450
l#2 0x00007fdb54b1b621 in parse_response (body=0x55b252cc64e0, content_type=<optimized out>, status_code=<optimized out>, request=0x55b2539206f0 [SnapdGetChange], self=0x55b254688280 [SnapdClient])
at ../snapd-glib/snapd-client.c:504
#3 read_cb (socket=<optimized out>, condition=<optimized out>, self=0x55b254688280 [SnapdClient]) at ../snapd-glib/snapd-client.c:696
#4 0x00007fdb664a58db in socket_source_dispatch (source=0x55b254c8e730, callback=0x7fdb54b1b2e0 <read_cb>, user_data=0x55b254688280) at ../../../gio/gsocket.c:4267
#5 0x00007fdb662a67df in g_main_dispatch (context=context@entry=0x55b24d30b6f0) at ../../../glib/gmain.c:3357
#6 0x00007fdb662a8a17 in g_main_context_dispatch_unlocked (context=0x55b24d30b6f0) at ../../../glib/gmain.c:4208
i#7 g_main_context_iterate_unlocked (context=context@entry=0x55b24d30b6f0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../glib/gmain.c:4273
#8 0x00007fdb662a9180 in g_main_context_iteration (context=context@entry=0x55b24d30b6f0, may_block=may_block@entry=1) at ../../../glib/gmain.c:4338
#9 0x00007fdb664e6305 in g_application_run (application=application@entry=0x55b24d2d26c0 [GsApplication], argc=argc@entry=2, argv=argv@entry=0x7ffde81ea458) at ../../../gio/gapplication.c:2715
#10 0x000055b24039f5bf in main (argc=2, argv=0x7ffde81ea458) at ../src/gs-main.c:49
(gdb) list
2370 SnapdChange *change,
2371 gpointer deprecated,
2372 gpointer user_data)
2373 {
2374 UninstallSingleAppData *app_data = user_data;
2375 GTask *task = app_data->task;
2376 GsPluginSnap *self = g_task_get_source_object (task);
2377 UninstallAppsData *data = g_task_get_task_data (task);
2378 GPtrArray *tasks;
2379 gint64 done = 0, total = 0;
(gdb) p app_data
$3 = (UninstallSingleAppData *) 0x0
(gdb)
Edited by Sid