shithub: qk1

Download patch

ref: 2e03c27e706b4df950e8d042e27203a64c324184
parent: 9912aef9564f75230bc4e77a01f1b72473c7cc4d
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Oct 15 14:53:08 EDT 2023

sizebuf_t: report the name of the buffer which got overflowed

--- a/cl_main.c
+++ b/cl_main.c
@@ -666,6 +666,7 @@
 void CL_Init (void)
 {	
 	SZ_Alloc (&cls.message, MAX_DATAGRAM);
+	cls.message.name = "cls.message";
 
 	cl_visedicts = Hunk_Alloc(MAX_VISEDICTS * sizeof(*cl_visedicts));
 	cl_efrags = Hunk_Alloc(MAX_EFRAGS * sizeof(*cl_efrags));
--- a/common.c
+++ b/common.c
@@ -367,11 +367,11 @@
 	
 	if(buf->cursize + length > buf->maxsize){
 		if(!buf->allowoverflow)
-			Host_Error("SZ_GetSpace: overflow without allowoverflow set");
+			Host_Error("SZ_GetSpace: %s: overflow without allowoverflow set", buf->name);
 		if(length > buf->maxsize)
-			Host_Error("SZ_GetSpace: %d is > full buffer size", length);
+			Host_Error("SZ_GetSpace: %s: %d is > full buffer size", buf->name, length);
 		buf->overflowed = true;
-		Con_Printf("SZ_GetSpace: overflow");
+		Con_Printf("SZ_GetSpace: %s: overflow", buf->name);
 		SZ_Clear(buf); 
 	}
 	data = buf->data + buf->cursize;
--- a/common.h
+++ b/common.h
@@ -4,6 +4,7 @@
 {
 	qboolean	allowoverflow;	// if false, do a fatal
 	qboolean	overflowed;		// set to true if the buffer size failed
+	char	*name;
 	byte	*data;
 	int		maxsize;
 	int		cursize;
--- a/sv_main.c
+++ b/sv_main.c
@@ -1134,15 +1134,18 @@
 	sv.datagram.maxsize = sizeof sv.datagram_buf;
 	sv.datagram.cursize = 0;
 	sv.datagram.data = sv.datagram_buf;
+	sv.datagram.name = "sv.datagram";
 	
 	sv.reliable_datagram.maxsize = sizeof sv.reliable_datagram_buf;
 	sv.reliable_datagram.cursize = 0;
 	sv.reliable_datagram.data = sv.reliable_datagram_buf;
-	
+	sv.reliable_datagram.name = "sv.reliable_datagram";
+
 	sv.signon.maxsize = sizeof sv.signon_buf;
 	sv.signon.cursize = 0;
 	sv.signon.data = sv.signon_buf;
-	
+	sv.signon.name = "sv.signon";
+
 // leave slots at start for clients only
 	sv.num_edicts = svs.maxclients+1;
 	for (i=0 ; i<svs.maxclients ; i++)