diff options
author | Edward Hervey <edward@centricular.com> | 2018-06-20 11:46:40 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2018-06-20 15:23:03 +0200 |
commit | d6224cc932c52f829a591a408fccbde68573cbda (patch) | |
tree | c94485e08f28f6d3ecdf67b52a91215455c03feb /libsoup/soup-socket-properties.c | |
parent | dba29f88dab86e09d76af143a44da26127c23dd8 (diff) | |
download | libsoup-d6224cc932c52f829a591a408fccbde68573cbda.tar.gz |
socket-properties: Implement MT-safe refcounting
Use atomic integer operation when dealing with refcounting, otherwise
one could very easily end-up in leaked (bad) properties or
double-freed (really bad) properties.
Diffstat (limited to 'libsoup/soup-socket-properties.c')
-rw-r--r-- | libsoup/soup-socket-properties.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libsoup/soup-socket-properties.c b/libsoup/soup-socket-properties.c index 8dea78c6..3c99be73 100644 --- a/libsoup/soup-socket-properties.c +++ b/libsoup/soup-socket-properties.c @@ -45,14 +45,14 @@ soup_socket_properties_new (GMainContext *async_context, SoupSocketProperties * soup_socket_properties_ref (SoupSocketProperties *props) { - props->ref_count++; + g_atomic_int_inc (&props->ref_count); return props; } void soup_socket_properties_unref (SoupSocketProperties *props) { - if (--props->ref_count) + if (!g_atomic_int_dec_and_test (&props->ref_count)) return; g_clear_pointer (&props->async_context, g_main_context_unref); |