1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

(trunk, libT) #5735 'segfault iside node_alloc' -- fixed with patch by benjarobin

This commit is contained in:
Jordan Lee 2014-07-06 20:06:45 +00:00
parent 74e16f78bd
commit d7f4478679

View file

@ -30,18 +30,22 @@ getRecycledNodesLock (void)
static tr_list* static tr_list*
node_alloc (void) 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; ret = recycled_nodes;
recycled_nodes = recycled_nodes->next; recycled_nodes = recycled_nodes->next;
tr_lockUnlock (getRecycledNodesLock ()); }
tr_lockUnlock (lock);
if (ret == NULL)
{
ret = tr_new (tr_list, 1);
} }
*ret = TR_LIST_CLEAR; *ret = TR_LIST_CLEAR;
@ -51,13 +55,15 @@ node_alloc (void)
static void static void
node_free (tr_list* node) node_free (tr_list* node)
{ {
tr_lock * lock = getRecycledNodesLock ();
if (node != NULL) if (node != NULL)
{ {
*node = TR_LIST_CLEAR; *node = TR_LIST_CLEAR;
tr_lockLock (getRecycledNodesLock ()); tr_lockLock (lock);
node->next = recycled_nodes; node->next = recycled_nodes;
recycled_nodes = node; recycled_nodes = node;
tr_lockUnlock (getRecycledNodesLock ()); tr_lockUnlock (lock);
} }
} }