From b127deeeb34ae898cf2ee08954ba76932acabeae Mon Sep 17 00:00:00 2001 From: Rod Widdowson Date: Wed, 27 Oct 2010 21:08:28 +0200 Subject: [PATCH] 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. Reviewed-on: http://gerrit.openafs.org/3175 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit e1ed8ab1d93906e1b556de332fa32601a9a489fc) Change-Id: I028a96a669fff3db48c05f2d894e9c6ef31fad12 Reviewed-on: http://gerrit.openafs.org/3240 Tested-by: BuildBot --- src/procmgmt/procmgmt_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 */ -- 2.39.5