You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-p2p/transmission/files/2.84-node_alloc-segfault.patch

56 lines
1.2 KiB

Index: libtransmission/list.c
===================================================================
--- libtransmission/list.c (revision 14318)
+++ libtransmission/list.c (revision 14319)
@@ -30,20 +30,24 @@
static tr_list*
node_alloc (void)
{
- tr_list * ret;
+ tr_list * ret = NULL;
+ tr_lock * lock = getRecycledNodesLock ();
- if (recycled_nodes == NULL)
+ tr_lockLock (lock);
+
+ if (recycled_nodes != NULL)
{
- ret = tr_new (tr_list, 1);
- }
- else
- {
- tr_lockLock (getRecycledNodesLock ());
ret = recycled_nodes;
recycled_nodes = recycled_nodes->next;
- tr_lockUnlock (getRecycledNodesLock ());
}
+ tr_lockUnlock (lock);
+
+ if (ret == NULL)
+ {
+ ret = tr_new (tr_list, 1);
+ }
+
*ret = TR_LIST_CLEAR;
return ret;
}
@@ -51,13 +55,15 @@
static void
node_free (tr_list* node)
{
+ tr_lock * lock = getRecycledNodesLock ();
+
if (node != NULL)
{
*node = TR_LIST_CLEAR;
- tr_lockLock (getRecycledNodesLock ());
+ tr_lockLock (lock);
node->next = recycled_nodes;
recycled_nodes = node;
- tr_lockUnlock (getRecycledNodesLock ());
+ tr_lockUnlock (lock);
}
}