shithub: qk1

Download patch

ref: 9eb97943b6836461e97e68b7d2eb5ff14f4d24cb
parent: 32a886a42047965215cf1a097d0e316d63455186
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Dec 27 17:41:37 EST 2023

bsp: don't reuse LIT memory if it failed to load, free it

--- a/model_bsp.c
+++ b/model_bsp.c
@@ -254,7 +254,6 @@
 	}
 
 	strcpy(s, mod->name);
-	lit = nil;
 	if((t = strrchr(s, '.')) != nil){
 		strcpy(t, ".lit");
 		if((lit = loadhunklmp(s, &litsz)) != nil && litsz >= 4+4+sz*3){
@@ -264,12 +263,12 @@
 			}else{
 				Con_Printf("%s: invalid/unsupported LIT file\n", s);
 			}
-		}else{
-			lit = nil;
 		}
+		Hunk_Free(lit);
+		lit = nil;
 	}
 
-	mod->lightdata = lit ? lit : Hunk_Alloc(sz*3);
+	mod->lightdata = Hunk_Alloc(sz*3);
 	for(i = 0; i < sz; i++){
 		mod->lightdata[i*3+0] = in[i];
 		mod->lightdata[i*3+1] = in[i];