Skip to content
  • Jeff King's avatar
    cat-file: handle NULL object_context.path · cc0ea7c9
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    Commit dc944b65
    
     (get_sha1_with_context: dynamically
    allocate oc->path, 2017-05-19) changed the rules that
    callers must follow for seeing if we parsed a path in the
    object name. The rules switched from "check if the oc.path
    buffer is empty" to "check if the oc.path pointer is NULL".
    But that commit forgot to update some sites in
    cat_one_file(), meaning we might dereference a NULL pointer.
    
    You can see this by making a path-aware request like
    --textconv without specifying --path, and giving an object
    name that doesn't have a path in it. Like:
    
      git cat-file --textconv HEAD
    
    which will reliably segfault.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    cc0ea7c9