File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -419,18 +419,30 @@ stderr_last_error(char *msg)
419
419
static void zend_mm_munmap (void * addr , size_t size )
420
420
{
421
421
#ifdef _WIN32
422
- MEMORY_BASIC_INFORMATION mbi ;
423
- if (VirtualQuery (addr , & mbi , sizeof (mbi )) == 0 ) {
422
+ if (VirtualFree (addr , 0 , MEM_RELEASE ) == 0 ) {
423
+ /** ERROR_INVALID_ADDRESS is expected when addr is not range start address */
424
+ if (GetLastError () != ERROR_INVALID_ADDRESS ) {
424
425
#if ZEND_MM_ERROR
425
- stderr_last_error ("VirtualQuery () failed" );
426
+ stderr_last_error ("VirtualFree () failed" );
426
427
#endif
427
- }
428
- addr = mbi .AllocationBase ;
429
-
430
- if (VirtualFree (addr , 0 , MEM_RELEASE ) == 0 ) {
428
+ return ;
429
+ }
430
+ SetLastError (0 );
431
+
432
+ MEMORY_BASIC_INFORMATION mbi ;
433
+ if (VirtualQuery (addr , & mbi , sizeof (mbi )) == 0 ) {
434
+ #if ZEND_MM_ERROR
435
+ stderr_last_error ("VirtualQuery() failed" );
436
+ #endif
437
+ return ;
438
+ }
439
+ addr = mbi .AllocationBase ;
440
+
441
+ if (VirtualFree (addr , 0 , MEM_RELEASE ) == 0 ) {
431
442
#if ZEND_MM_ERROR
432
- stderr_last_error ("VirtualFree() failed" );
443
+ stderr_last_error ("VirtualFree() failed" );
433
444
#endif
445
+ }
434
446
}
435
447
#else
436
448
if (munmap (addr , size ) != 0 ) {
You can’t perform that action at this time.
0 commit comments