This commit is contained in:
+10
-4
@@ -3606,10 +3606,16 @@ static int PH7_builtin_closedir(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||
ph7_result_bool(pCtx, 0);
|
||||
return PH7_OK;
|
||||
}
|
||||
/* Perform the requested operation */
|
||||
pStream->xCloseDir(pDev->pHandle);
|
||||
/* Release the private stucture */
|
||||
ReleaseIOPrivate(pCtx, pDev);
|
||||
/* Resources are copied raw pointers. Keep a directory-only tombstone until
|
||||
* VM backend release, so stale aliases cannot dereference freed storage or
|
||||
* close a newly opened handle at the same address. Invalidate before the
|
||||
* device callback, which may re-enter the VM. One tiny wrapper per successful
|
||||
* open is retained; the OS handle and buffer are released immediately. */
|
||||
void *pHandle = pDev->pHandle;
|
||||
pDev->iMagic = 0x2126;
|
||||
pDev->pHandle = 0;
|
||||
SyBlobRelease(&pDev->sBuffer);
|
||||
pStream->xCloseDir(pHandle);
|
||||
PH7_MemObjRelease(apArg[0]);
|
||||
return PH7_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user