Skip to content

Commit cfb0ff1

Browse files
committed
Fixed memory leak and memory access
1 parent 49a0ae9 commit cfb0ff1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Renderer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ void renderText(const std::string& fontPath, int fontSize, const std::pair<float
4747
}
4848

4949
SDL_PixelFormat* format = SDL_AllocFormat(SDL_PIXELFORMAT_RGB888);
50-
5150
SDL_Surface* imageSurface = SDL_ConvertSurface(textSurface, format, 0);
52-
5351
SDL_FreeSurface(textSurface);
52+
SDL_FreeFormat(format);
5453

5554
GLuint texture;
5655
glGenTextures(1, &texture);
5756
glBindTexture(GL_TEXTURE_2D, texture);
5857

59-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textSurface->w, textSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageSurface->pixels);
58+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageSurface->w, imageSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageSurface->pixels);
6059
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
6160
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
6261

0 commit comments

Comments
 (0)