• Jeremy Hylton's avatar
    Fix memory leak in BTrees. · c294cd02
    Jeremy Hylton authored
    The Mapping_update() method iterated over a sequence of 2-tuples, but
    held an extra reference to the sequence.  The sequence object was
    DECREFed on an error exit but not on the normal return.
    
    The fix reworks the control flow of the function to make the reference
    counting behavior a little clearer:
    
       - Test for call with no arguments and return immediately if so.
    
       - If the argument is a sequence, don't INCREF it.
    
       - If the argument passed isn't a sequence, call its items() method
         and store the result in the local variables seq and items.
    
       - On exit, do Py_XDECREF(items).  This will do a decref only if a
         the second case above applied.
    
    Two other minor nits:
    
       - Make consistent use of spaces around = in assignments (as opposed
         to a fix of both)
    
       - Remove assignment from conditional expression.
    c294cd02
BucketTemplate.c 30.1 KB