shithub: cstory

Download patch

ref: 29c84ae2224b690313c69f73b6f4d55f6cb944b9
parent: dddf9688108d36a84898b825aa3d7f81e1eeffd7
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Aug 13 02:36:31 EDT 2019

Fixes

--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -54,12 +54,22 @@
 	renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
 
 	if (renderer == NULL)
-		return FALSE;
+		return NULL;
 
 	int width, height;
 	SDL_GetRendererOutputSize(renderer, &width, &height);
 	framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height);
 
+	if (framebuffer.texture == NULL)
+	{
+		SDL_DestroyRenderer(renderer);
+		return NULL;
+	}
+
+	framebuffer.alpha = TRUE;
+	framebuffer.width = width;
+	framebuffer.height = height;
+
 	return &framebuffer;
 }
 
@@ -119,7 +129,7 @@
 
 	*pitch = surface->width * (surface->alpha ? 4 : 3);
 
-	surface->pixels = (unsigned char*)malloc(surface->width * surface->height * (surface->alpha ? 4 : 3));
+	surface->pixels = (unsigned char*)malloc(surface->height * *pitch);
 
 	return surface->pixels;
 }
@@ -128,8 +138,6 @@
 {
 	if (surface == NULL)
 		return;
-
-	SDL_UnlockTexture(surface->texture);
 
 	if (surface->alpha)
 	{