diff options
Diffstat (limited to 'usage.c')
-rw-r--r-- | usage.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -6,6 +6,8 @@ #include "git-compat-util.h" #include "cache.h" +static int dying; + void vreportf(const char *prefix, const char *err, va_list params) { char msg[4096]; @@ -82,6 +84,12 @@ void NORETURN die(const char *err, ...) { va_list params; + if (dying) { + fputs("fatal: recursion detected in die handler\n", stderr); + exit(128); + } + dying = 1; + va_start(params, err); die_routine(err, params); va_end(params); @@ -94,6 +102,13 @@ void NORETURN die_errno(const char *fmt, ...) char str_error[256], *err; int i, j; + if (dying) { + fputs("fatal: recursion detected in die_errno handler\n", + stderr); + exit(128); + } + dying = 1; + err = strerror(errno); for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) { if ((str_error[j++] = err[i++]) != '%') @@ -115,6 +130,7 @@ void NORETURN die_errno(const char *fmt, ...) va_end(params); } +#undef error int error(const char *err, ...) { va_list params; |