1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

errno: fix non-windows builds after af0216251b

This commit is contained in:
Daniel Stenberg 2017-07-10 13:58:35 +02:00
parent 793e831bbf
commit a5834e525d
2 changed files with 8 additions and 6 deletions

View File

@ -147,7 +147,7 @@ static bool countcheck(const char *func, int line, const char *source)
source, line, func); source, line, func);
fflush(logfile); /* because it might crash now */ fflush(logfile); /* because it might crash now */
} }
SET_ERRNO(ENOMEM); errno = ENOMEM;
return TRUE; /* RETURN ERROR! */ return TRUE; /* RETURN ERROR! */
} }
else else

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2004 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2004 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -631,14 +631,16 @@ const char *Curl_strerror(struct connectdata *conn, int err)
char *buf, *p; char *buf, *p;
size_t max; size_t max;
int old_errno; int old_errno;
#ifdef WIN32
DWORD old_win_err; DWORD old_win_err;
#endif
DEBUGASSERT(conn); DEBUGASSERT(conn);
DEBUGASSERT(err >= 0); DEBUGASSERT(err >= 0);
old_errno = errno; old_errno = errno;
#ifdef WIN32
old_win_err = GetLastError(); old_win_err = GetLastError();
#endif
buf = conn->syserr_buf; buf = conn->syserr_buf;
max = sizeof(conn->syserr_buf)-1; max = sizeof(conn->syserr_buf)-1;
*buf = '\0'; *buf = '\0';
@ -725,10 +727,10 @@ const char *Curl_strerror(struct connectdata *conn, int err)
p = strrchr(buf, '\r'); p = strrchr(buf, '\r');
if(p && (p - buf) >= 1) if(p && (p - buf) >= 1)
*p = '\0'; *p = '\0';
#ifdef WIN32
if(old_win_err != GetLastError()) if(old_win_err != GetLastError())
SetLastError(old_win_err); SetLastError(old_win_err);
#endif
if(errno != old_errno) if(errno != old_errno)
errno = old_errno; errno = old_errno;