If I have to guess, this part looks suspicious:
```
ret = mach_vm_region( process_port, ®ion_address, ®ion_size, VM_REGION_BASIC_INFO_64,
(vm_region_info_t)&info, &info_count, &object_name );
```
((vm_region_info_t)&info). That seems like the parameter which address on stack is below our 'written' (so writing past it can do this), and it is suspiciously casted.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/8834#note_120935
From this disassembly, %r8 (which is 'written' parameter) is saved on stack (`movq %r8, -0x68(%rbp)`), it is moved to %rdx in the end for assignment. I think it is likely that some code inside the fucntion before '*written' assignment smashes the stack and 'written' (and a whole change introduced by this patch) is a random victim.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/8834#note_120934
The code in `req_write_process_memory` calling write_process_memory is:
```
...
if ((process = get_process_from_handle( req->handle, PROCESS_VM_WRITE )))
{
data_size_t len = get_req_data_size();
reply->written = 0;
if (len) write_process_memory( process, req->addr, len, get_req_data(), &reply->written );
release_object( process );
}
```
reply->written was just assigned and it didn't crash. However, address of that which got to `write_process_memory` is bogus.
Can it happen by any chance that something went wrong with the build, if not assuming some mindbreaking guesses or compiler errors that could happen if some compiled .o files are stale??
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/8834#note_120932
Fixes: 2127e9ae7d90466f3b8883708799047214409832
---
Fixes a crash on macOS. Perhaps the extensions string regularly has a trailing space on other platforms?
The previous filter_extensions_list method set `end` differently and avoided this case.
--
v4: opengl32: Avoid null pointer dereferences when filtering extensions.
https://gitlab.winehq.org/wine/wine/-/merge_requests/9375