Skip to content
  • Jim Meyering's avatar
    fix "git apply --index ..." not to deref NULL · 2c93286a
    Jim Meyering authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    I noticed this when "git am CORRUPTED" unexpectedly failed with an
    odd diagnostic, and even removed one of the files it was supposed
    to have patched.
    
    Reproduce with any valid old/new patch from which you have removed
    the "+++ b/FILE" line.  You'll see a diagnostic like this
    
        fatal: unable to write file '(null)' mode 100644: Bad address
    
    and you'll find that FILE has been removed.
    
    The above is on glibc-based systems.  On other systems, rather than
    getting "null", you may provoke a segfault as git tries to
    dereference the NULL file name.
    
    Signed-off-by: default avatarJim Meyering <meyering@redhat.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    2c93286a