windows: preserve lasterror prior to calling free
authorRod Widdowson <rdw@steadingsoftware.com>
Wed, 27 Oct 2010 19:08:28 +0000 (21:08 +0200)
committerDerrick Brashear <shadow@dementia.org>
Wed, 27 Oct 2010 22:22:26 +0000 (15:22 -0700)
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 <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/procmgmt/procmgmt_nt.c

index 1720534..8f16c21 100644 (file)
@@ -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 */