From e295f483d975d7e926bb5a2527aeab10c150dd4c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 1 Jan 2021 14:46:31 +0100 Subject: [PATCH] save errno in sys_error() the print functions prior to perror() might otherwise clobber it. --- src/util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util.c b/src/util.c index 7f8c453..dd6b12c 100644 --- a/src/util.c +++ b/src/util.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -154,9 +155,11 @@ vsys_error( const char *msg, va_list va ) { char buf[1024]; + int errno_bak = errno; flushn(); if ((uint)vsnprintf( buf, sizeof(buf), msg, va ) >= sizeof(buf)) oob(); + errno = errno_bak; perror( buf ); }