render: Plug a memory leak in AddGlyph. (#23286)
AddGlyph was missing the FreePicture() call that DeleteGlyph used, resulting in a memory leak when more than one Glyph was added in a RenderAddGlyphs request. Since the code in AddGlyph and DeleteGlyph is identical, move into a static function to avoid such mistakes in the future. X.Org Bug 23286 <http://bugs.freedesktop.org/show_bug.cgi?id=23286>
This commit is contained in:
parent
3db28f92b0
commit
f772014c43
|
@ -272,13 +272,31 @@ CheckDuplicates (GlyphHashPtr hash, char *where)
|
||||||
#define DuplicateRef(a,b)
|
#define DuplicateRef(a,b)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
FreeGlyphPicture(GlyphPtr glyph)
|
||||||
|
{
|
||||||
|
PictureScreenPtr ps;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < screenInfo.numScreens; i++)
|
||||||
|
{
|
||||||
|
ScreenPtr pScreen = screenInfo.screens[i];
|
||||||
|
|
||||||
|
FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
|
||||||
|
|
||||||
|
ps = GetPictureScreenIfSet (pScreen);
|
||||||
|
if (ps)
|
||||||
|
(*ps->UnrealizeGlyph) (pScreen, glyph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FreeGlyph (GlyphPtr glyph, int format)
|
FreeGlyph (GlyphPtr glyph, int format)
|
||||||
{
|
{
|
||||||
CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
|
CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
|
||||||
if (--glyph->refcnt == 0)
|
if (--glyph->refcnt == 0)
|
||||||
{
|
{
|
||||||
PictureScreenPtr ps;
|
|
||||||
GlyphRefPtr gr;
|
GlyphRefPtr gr;
|
||||||
int i;
|
int i;
|
||||||
int first;
|
int first;
|
||||||
|
@ -305,17 +323,7 @@ FreeGlyph (GlyphPtr glyph, int format)
|
||||||
globalGlyphs[format].tableEntries--;
|
globalGlyphs[format].tableEntries--;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < screenInfo.numScreens; i++)
|
FreeGlyphPicture(glyph);
|
||||||
{
|
|
||||||
ScreenPtr pScreen = screenInfo.screens[i];
|
|
||||||
|
|
||||||
FreePicture ((pointer) GlyphPicture (glyph)[i], 0);
|
|
||||||
|
|
||||||
ps = GetPictureScreenIfSet (pScreen);
|
|
||||||
if (ps)
|
|
||||||
(*ps->UnrealizeGlyph) (pScreen, glyph);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeGlyphPrivates(glyph);
|
FreeGlyphPrivates(glyph);
|
||||||
xfree (glyph);
|
xfree (glyph);
|
||||||
}
|
}
|
||||||
|
@ -334,15 +342,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
|
||||||
TRUE, glyph->sha1);
|
TRUE, glyph->sha1);
|
||||||
if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph)
|
if (gr->glyph && gr->glyph != DeletedGlyph && gr->glyph != glyph)
|
||||||
{
|
{
|
||||||
PictureScreenPtr ps;
|
FreeGlyphPicture(glyph);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < screenInfo.numScreens; i++)
|
|
||||||
{
|
|
||||||
ps = GetPictureScreenIfSet (screenInfo.screens[i]);
|
|
||||||
if (ps)
|
|
||||||
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
|
|
||||||
}
|
|
||||||
FreeGlyphPrivates(glyph);
|
FreeGlyphPrivates(glyph);
|
||||||
xfree (glyph);
|
xfree (glyph);
|
||||||
glyph = gr->glyph;
|
glyph = gr->glyph;
|
||||||
|
|
Loading…
Reference in New Issue