From f497a24fe9cf0119f328e49b55aa6f6a0e20b5bf Mon Sep 17 00:00:00 2001
From: Hayden Kowalchuk <hayden@hkowsoftware.com>
Date: Sun, 22 Sep 2019 19:50:40 -0400
Subject: [PATCH] fix: forgot a free to match a malloc

---
 GL/draw.c    |  2 ++
 GL/state.c   | 12 +++++++-----
 GL/texture.c |  1 +
 Makefile     |  2 +-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/GL/draw.c b/GL/draw.c
index 7ab8501..cfba2f8 100644
--- a/GL/draw.c
+++ b/GL/draw.c
@@ -820,6 +820,8 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
             genTriangleStrip(_glSubmissionTargetStart(target), count);
             break;
         default:
+            printf("mode: 0x%08x\n", mode);
+            fflush(stdout);
             assert(0 && "Not Implemented");
         }
 
diff --git a/GL/state.c b/GL/state.c
index 3ea6220..4711ed3 100644
--- a/GL/state.c
+++ b/GL/state.c
@@ -206,11 +206,13 @@ void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit) {
         /* If we don't have complete mipmaps, and yet mipmapping was enabled, we disable texturing.
          * This is effectively what standard GL does (it renders a white texture)
          */
-        if(!_glIsMipmapComplete(tx1) && enableMipmaps) {
-            context->txr.enable = PVR_TEXTURE_DISABLE;
-            context->txr.base = 0;
-            context->txr.format = 0;
-            return;
+        if(!_glIsMipmapComplete(tx1)) {
+            filter = PVR_FILTER_BILINEAR;
+            enableMipmaps = GL_FALSE;
+            //context->txr.enable = PVR_TEXTURE_DISABLE;
+            //context->txr.base = 0;
+            //context->txr.format = 0;
+            //return;
         }
     } else {
         if(tx1->minFilter == GL_LINEAR && tx1->magFilter == GL_LINEAR) {
diff --git a/GL/texture.c b/GL/texture.c
index 038d6c3..31eb852 100644
--- a/GL/texture.c
+++ b/GL/texture.c
@@ -923,6 +923,7 @@ void _glAllocateSpaceForMipmaps(TextureObject* active) {
 
     /* If there was existing data, then copy it where it should go */
     memcpy(_glGetMipmapLocation(active,0), temp, size);
+    free(temp);
 }
 
 void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
diff --git a/Makefile b/Makefile
index 3915513..f4d33b5 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ OBJS += containers/stack.o containers/named_array.o containers/aligned_vector.o
 SUBDIRS =
 
 EXTRA_CFLAGS=  -Wall -Wextra -Wstrict-aliasing=0
-KOS_CFLAGS += -ffast-math -O2 -funroll-loops -fsingle-precision-constant -Iinclude -funsafe-math-optimizations -DBUILD_LIBGL
+KOS_CFLAGS += -ffast-math -O2 -funroll-loops -fsingle-precision-constant -Iinclude -funsafe-math-optimizations -DBUILD_LIBGL $(EXTRA_CFLAGS)
 #KOS_CFLAGS += -O1 -mlra -Iinclude -DBUILD_LIBGL -Wall -Wextra
 #GCC5_FLAGS = -mfsca -mfsrra -mlra