• Show log

    Commit

  • Hash : 21766702
    Author : Patrick Steinhardt
    Date : 2016-06-27T15:20:20

    blame: do not decrement commit refcount in make_origin
    
    When we create a blame origin, we try to look up the blob that is
    to be blamed at a certain revision. When this lookup fails, e.g.
    because the file did not exist at that certain revision, we fail
    to create the blame origin and return `NULL`. The blame origin
    that we have just allocated is thereby free'd with
    `origin_decref`.
    
    The `origin_decref` function does not only decrement reference
    counts for the blame origin, though, but also for its commit and
    blob. When this is done in the error case, we will cause an
    uneven reference count for these objects. This may result in
    hard-to-debug failures at seemingly unrelated code paths, where
    we try to access these objects when they in fact have already
    been free'd.
    
    Fix the issue by refactoring `make_origin` such that we only
    allocate the object after the only function that may fail so that
    we do not have to call `origin_decref` at all. Also fix the
    `pass_blame` function, which indirectly calls `make_origin`, to
    free the commit when `make_origin` failed.