Commit e13c6464 authored by Christoph Reiter's avatar Christoph Reiter 🐍

gcancellable: add back lost NULL check in g_cancellable_cancel()

Commit f975858e removed the NULL check in g_cancellable_cancel() by
accident which makes it crash when called with NULL.

Add the check back and add a test so this doesn't happen again.

Fixes #1710
parent aeb7dbad
Pipeline #65536 passed with stages
in 11 minutes and 1 second
......@@ -484,7 +484,7 @@ g_cancellable_cancel (GCancellable *cancellable)
GCancellablePrivate *priv;
if (g_cancellable_is_cancelled (cancellable))
if (cancellable == NULL || g_cancellable_is_cancelled (cancellable))
priv = cancellable->priv;
......@@ -216,12 +216,19 @@ test_cancel_multiple_concurrent (void)
g_main_loop_unref (loop);
static void
test_cancel_null (void)
g_cancellable_cancel (NULL);
main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/cancellable/multiple-concurrent", test_cancel_multiple_concurrent);
g_test_add_func ("/cancellable/null", test_cancel_null);
return g_test_run ();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment