]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix a crash on shutdown when using developer_memory 1 (the conbuffer_t
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 14 Dec 2009 04:13:04 +0000 (04:13 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 14 Dec 2009 04:13:04 +0000 (04:13 +0000)
is being freed and prints messages while doing so)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9581 d7cf8633-e32d-0410-b094-e92efae38249

console.c
console.h

index 2798199bcdf112020c086670a52a4416873532a9..71a5f86928ccea41619a75c690db6287bb0eea85 100644 (file)
--- a/console.c
+++ b/console.c
@@ -92,6 +92,7 @@ char rcon_redirect_buffer[1400];
 
 void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool)
 {
+       buf->active = true;
        buf->textsize = textsize;
        buf->text = (char *) Mem_Alloc(mempool, textsize);
        buf->maxlines = maxlines;
@@ -117,6 +118,7 @@ ConBuffer_Shutdown
 */
 void ConBuffer_Shutdown(conbuffer_t *buf)
 {
+       buf->active = false;
        Mem_Free(buf->text);
        Mem_Free(buf->lines);
        buf->text = NULL;
@@ -227,6 +229,10 @@ void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, int mask)
        char *putpos;
        con_lineinfo_t *p;
 
+       // developer_memory 1 during shutdown prints while conbuffer_t is being freed
+       if (!buf->active)
+               return;
+
        ConBuffer_FixTimes(buf);
 
        if(len >= buf->textsize)
index 438e9ca21e2ea40b46eae26621d73a2de23f554c..338690ebfd53d014c5185b975613c700f288dabc 100644 (file)
--- a/console.h
+++ b/console.h
@@ -99,6 +99,7 @@ con_lineinfo_t;
 
 typedef struct conbuffer_s
 {
+       qboolean active;
        int textsize;
        char *text;
        int maxlines;