$ patch -d no-such-dir patch: **** Can't change to directory no-such-dir : No such file or directory Segmentation fault With gdb, the backtrace looks like this: Program received signal SIGSEGV, Segmentation fault. gl_list_iterator_inline (list=0x0) at ../lib/gl_list.h:762 762 ->iterator (list); (gdb) bt #0 gl_list_iterator_inline (list=0x0) at ../lib/gl_list.h:762 #1 forget_output_files () at patch.c:1935 #2 cleanup () at patch.c:1978 #3 0x0000000000407128 in fatal_exit (sig=sig@entry=0) at patch.c:1953 #4 0x000000000040d358 in pfatal ( format=format@entry=0x419319 "Can't change to directory %s") at util.c:952 #5 0x0000000000403016 in get_some_switches () at patch.c:875 #6 main (argc=<optimized out>, argv=<optimized out>) at patch.c:156 Seems like forget_output_files should check whether or not files_to_output has been initialized. Not sure whether comparing it to NULL is appropriate or not. Also reported this upstream: https://savannah.gnu.org/bugs/index.php?40049 Not sure whether you want to introduce a patch or wait for upstream.
Arch has a patch for that, used since Dec-2012: https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/patch
Upstream indicates that this is already fixed in git. The relevant commit is http://git.savannah.gnu.org/cgit/patch.git/commit/?id=291ec175812b7ba291d124e4 (In reply to Paul Bredbury from comment #1) > Arch has a patch for that, used since Dec-2012: The above is identical to that one: they got it from the same git repository. I should have considered that possibility, and checked the official repo. In any case, this makes the patch you provided pretty official.
+*patch-2.7.1-r3 (15 Oct 2013) + + 15 Oct 2013; Lars Wendler <polynomial-c@gentoo.org> -patch-2.7.1.ebuild, + -patch-2.7.1-r1.ebuild, patch-2.7.1-r2.ebuild, +patch-2.7.1-r3.ebuild, + +files/patch-2.7.1-initialize_data_structures_early_enough.patch, + +files/patch-2.7.1-prevent_depend_on_autotools.patch: + Revbump to fix segfault on nonexisting dir. Thanks to Martin von Gagern for + reporting this in bug #485182. Removed old versions. +