]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix nasty bug with dp_fonts structure expanding, once dp_fonts.f being reallocated...
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 22 Oct 2010 21:56:14 +0000 (21:56 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 22 Oct 2010 22:01:54 +0000 (00:01 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10559 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=58f3c6005dba620506c939db3acb94a0e5bf1dcb

gl_draw.c

index 6b5c76222ba1ec9d8d902d0569c82804d64ff059..05cbd15ce9b08349865e5624356ffd7156aa0933 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -721,7 +721,7 @@ void LoadFont(qboolean override, const char *name, dp_font_t *fnt, float scale,
 extern cvar_t developer_font;
 dp_font_t *FindFont(const char *title, qboolean allocate_new)
 {
-       int i;
+       int i, oldsize;
 
        // find font
        for(i = 0; i < dp_fonts.maxsize; ++i)
@@ -740,14 +740,18 @@ dp_font_t *FindFont(const char *title, qboolean allocate_new)
                        }
                }
                // if no any 'free' fonts - expand buffer
-               i = dp_fonts.maxsize;
+               oldsize = dp_fonts.maxsize;
                dp_fonts.maxsize = dp_fonts.maxsize + FONTS_EXPAND;
                if (developer_font.integer)
-                       Con_Printf("FindFont: enlarging fonts buffer (%i -> %i)\n", i, dp_fonts.maxsize);
-               dp_fonts.f = Mem_Realloc(fonts_mempool, dp_fonts.f, sizeof(dp_font_t) * dp_fonts.maxsize);
+                       Con_Printf("FindFont: enlarging fonts buffer (%i -> %i)\n", oldsize, dp_fonts.maxsize);
+               dp_fonts.f = (dp_font_t *)Mem_Realloc(fonts_mempool, dp_fonts.f, sizeof(dp_font_t) * dp_fonts.maxsize);
+               // relink ft2 structures
+               for(i = 0; i < oldsize; ++i)
+                       if (dp_fonts.f[i].ft2)
+                               dp_fonts.f[i].ft2->settings = &dp_fonts.f[i].settings;
                // register a font in first expanded slot
-               strlcpy(dp_fonts.f[i].title, title, sizeof(dp_fonts.f[i].title));
-               return &dp_fonts.f[i];
+               strlcpy(dp_fonts.f[oldsize].title, title, sizeof(dp_fonts.f[oldsize].title));
+               return &dp_fonts.f[oldsize];
        }
        return NULL;
 }