gsocketclient: Fix passing NULL to g_task_get_cancellable()

Merged Philip Withnall requested to merge pwithnall/glib:2687-socket-cancellable into main

Fix a regression from commit abddb42d, where it could pass NULL to g_task_get_cancellable(), triggering a critical warning. This could happen because the lifetime of data->task is not as long as the lifetime of the ConnectionAttempt, but the code assumed it was.

Fix the problem by keeping a strong ref to that GCancellable around until the ConnectionAttempt is finished being destroyed.

Signed-off-by: Philip Withnall

Fixes: #2687 (closed)

Closes #2687 (closed)

Merge request reports