lwp: Avoid freeing 'stackmemory' on AIX32 26/13426/2
authorAndrew Deason <adeason@sinenomine.net>
Mon, 14 Jan 2019 23:12:27 +0000 (17:12 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Wed, 16 Jan 2019 00:30:36 +0000 (19:30 -0500)
Commit 55013a11 (lwp: Fix possible memory leak from scan-build) added
some free() calls to some otherwise-leaked memory. However, one of
these calls frees the 'stackmemory' pointer, which on AIX32 is not a
pointer from malloc/calloc, but calculated from reserveFromStack().

To avoid corrupting the heap, skip this free call on AIX32. This
commit adds another #ifdef to avoid this, which is unfortunate, but
this is also how the free is avoided in the existing code for
Free_PCB().

Change-Id: I6c4518f810e56c362ee744f250747fe8fc765b13
Reviewed-on: https://gerrit.openafs.org/13426
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/lwp/lwp.c

index de9d651..7599475 100644 (file)
@@ -355,7 +355,9 @@ LWP_CreateProcess(void *(*ep) (void *), int stacksize, int priority, void *parm,
 #endif
        if (priority < 0 || priority >= MAX_PRIORITIES) {
            free(temp);
+#ifndef AFS_AIX32_ENV
            free(stackmemory);
+#endif
            Set_LWP_RC();
            return LWP_EBADPRI;
        }