From 66ec96d52c7ff0a8cd5ae29be88fcbab505569fe Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Thu, 14 Dec 2017 16:40:14 +0100 Subject: [PATCH] win-capture: Fix memory capture crash on new capture If the target process re-creates its D3D context, the game capture tick can trigger before the capture is setup, in which case OBS gets a CAPTURE_RETRY message. However with the memory capture method, it continues to try and copy from the shared memory pointer which is no longer valid, resulting in a crash. The fix uses the old texture until the next tick at which point the new capture should be ready for use. --- plugins/win-capture/game-capture.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index 8372233b7..764bc601f 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -1429,12 +1429,17 @@ static inline void copy_16bit_tex(struct game_capture *gc, int cur_texture, static void copy_shmem_tex(struct game_capture *gc) { - int cur_texture = gc->shmem_data->last_tex; + int cur_texture; HANDLE mutex = NULL; uint32_t pitch; int next_texture; uint8_t *data; + if (!gc->shmem_data) + return; + + cur_texture = gc->shmem_data->last_tex; + if (cur_texture < 0 || cur_texture > 1) return;