Skip to content
  • Jeff King's avatar
    tempfile: handle NULL tempfile pointers gracefully · f5b4dc76
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    The tempfile functions all take pointers to tempfile
    objects, but do not check whether the argument is NULL.
    This isn't a big deal in practice, since the lifetime of any
    tempfile object is defined to last for the whole program. So
    even if we try to call delete_tempfile() on an
    already-deleted tempfile, our "active" check will tell us
    that it's a noop.
    
    In preparation for transitioning to a new system that
    loosens the "tempfile objects can never be freed" rule,
    let's tighten up our active checks:
    
      1. A NULL pointer is now defined as "inactive" (so it will
         BUG for most functions, but works as a silent noop for
         things like delete_tempfile).
    
      2. Functions should always do the "active" check before
         looking at any of the struct fields.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    f5b4dc76