foxygit / doom Log in
commit 0bdb203dc87a45b85f1fbe5651fc40e5b286cb02
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Tue Mar 17 08:05:50 2015 +0100
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Tue Mar 17 08:05:50 2015 +0100

    Fix possible crash with software renderer

    https://github.com/bradharding/doomretro/commit/7dbbd2ccd293f3a2a1df7a03971f8dd24d0d2a5d
---
 src/i_video.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index fd11eb2f..ba5acc46 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1107,9 +1107,11 @@ void I_FinishUpdate (void)

     // Update the texture with the content of the 32-bit RGBA buffer

-    SDL_LockTexture(texture, NULL, &pixels, &pitch);
-    memcpy(pixels, rgbabuffer->pixels, SCREENHEIGHT*pitch);
-    SDL_UnlockTexture(texture);
+    if (!SDL_LockTexture(texture, NULL, &pixels, &pitch))
+    {
+	memcpy(pixels, rgbabuffer->pixels, SCREENHEIGHT*pitch);
+	SDL_UnlockTexture(texture);
+    }

     // Render the texture into the window