From: Rod Widdowson Date: Wed, 27 Oct 2010 19:08:28 +0000 (+0200) Subject: windows: preserve lasterror prior to calling free X-Git-Tag: upstream/1.8.0_pre1^2~4606 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e1ed8ab1d93906e1b556de332fa32601a9a489fc;p=packages%2Fo%2Fopenafs.git windows: preserve lasterror prior to calling free free() destroys GetLastError, so preserve it before giving back all the buffers. Then if the create process failed we have something sensible to log. Change-Id: Ibb8bb870230f9c4e96f5ec9d4948552616cd7456 Reviewed-on: http://gerrit.openafs.org/3175 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/procmgmt/procmgmt_nt.c b/src/procmgmt/procmgmt_nt.c index 172053461..8f16c21c3 100644 --- a/src/procmgmt/procmgmt_nt.c +++ b/src/procmgmt/procmgmt_nt.c @@ -882,6 +882,7 @@ pmgt_ProcessSpawnVEB(const char *spath, char *sargv[], char *senvp[], DWORD monitorId, createFlags; BOOL passingBuffer = (sdatap != NULL && sdatalen > 0); BOOL fsuccess; + int lasterror; /* verify arguments */ if (!spath || !sargv) { @@ -982,13 +983,14 @@ pmgt_ProcessSpawnVEB(const char *spath, char *sargv[], char *senvp[], &startInfo, /* startup info block */ &procInfo); + lasterror = GetLastError(); free(pathbuf); free(argbuf); free(envbuf); if (!fsuccess) { /* failed to spawn process */ - errno = nterr_nt2unix(GetLastError(), ENOENT); + errno = nterr_nt2unix(lasterror, ENOENT); (void)pthread_mutex_lock(&procTableLock); procTable[tidx].p_reserved = FALSE; /* mark entry as not reserved */