Changeset 14319


Ignore:
Timestamp:
Jul 6, 2014, 8:06:45 PM (6 years ago)
Author:
jordan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/list.c

    r14241 r14319  
    3131node_alloc (void)
    3232{
    33   tr_list * ret;
    34 
    35   if (recycled_nodes == NULL)
    36     {
    37       ret = tr_new (tr_list, 1);
    38     }
    39   else
    40     {
    41       tr_lockLock (getRecycledNodesLock ());
     33  tr_list * ret = NULL;
     34  tr_lock * lock = getRecycledNodesLock ();
     35
     36  tr_lockLock (lock);
     37
     38  if (recycled_nodes != NULL)
     39    {
    4240      ret = recycled_nodes;
    4341      recycled_nodes = recycled_nodes->next;
    44       tr_lockUnlock (getRecycledNodesLock ());
     42    }
     43
     44  tr_lockUnlock (lock);
     45
     46  if (ret == NULL)
     47    {
     48      ret = tr_new (tr_list, 1);
    4549    }
    4650
     
    5256node_free (tr_list* node)
    5357{
     58  tr_lock * lock = getRecycledNodesLock ();
     59
    5460  if (node != NULL)
    5561    {
    5662      *node = TR_LIST_CLEAR;
    57       tr_lockLock (getRecycledNodesLock ());
     63      tr_lockLock (lock);
    5864      node->next = recycled_nodes;
    5965      recycled_nodes = node;
    60       tr_lockUnlock (getRecycledNodesLock ());
     66      tr_lockUnlock (lock);
    6167    }
    6268}
Note: See TracChangeset for help on using the changeset viewer.