cvs: gd /libgd/src gdft.c
[email protected] ("Takeshi Abe") Wed, 25 Mar 2009 17:02:01 -0000
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvstabe1238000521@cvsserver> |
tabe Wed Mar 25 17:02:01 2009 UTC
Modified files:
/gd/libgd/src gdft.c
Log:
fixed memory leaks through failure
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gdft.c?r1=1.38&r2=1.39&diff_format=u
Index: gd/libgd/src/gdft.c
diff -u gd/libgd/src/gdft.c:1.38 gd/libgd/src/gdft.c:1.39
--- gd/libgd/src/gdft.c:1.38 Sat Aug 2 14:43:33 2008
+++ gd/libgd/src/gdft.c Wed Mar 25 17:02:01 2009
@@ -1083,6 +1083,7 @@
else
{
/* No character set found! */
+ gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "No character set found";
}
@@ -1251,7 +1252,11 @@
xshow_alloc = 100;
strex->xshow = gdMalloc(xshow_alloc);
if (!strex->xshow) {
- return 0;
+ if (tmpstr)
+ gdFree (tmpstr);
+ gdCacheDelete (tc_cache);
+ gdMutexUnlock (gdFontCacheMutex);
+ return "Problem allocating memory";
}
xshow_pos = 0;
}
@@ -1259,7 +1264,11 @@
xshow_alloc += 100;
strex->xshow = gdRealloc(strex->xshow, xshow_alloc);
if (!strex->xshow) {
- return 0;
+ if (tmpstr)
+ gdFree (tmpstr);
+ gdCacheDelete (tc_cache);
+ gdMutexUnlock (gdFontCacheMutex);
+ return "Problem allocating memory";
}
}
xshow_pos += sprintf(strex->xshow + xshow_pos, "%g ",
@@ -1271,6 +1280,8 @@
err = FT_Load_Glyph (face, glyph_index, render_mode);
if (err)
{
+ if (tmpstr)
+ gdFree (tmpstr);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem loading glyph";
@@ -1324,6 +1335,8 @@
err = FT_Load_Glyph (face, glyph_index, render_mode);
if (err)
{
+ if (tmpstr)
+ gdFree (tmpstr);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem loading glyph";
@@ -1337,6 +1350,8 @@
err = FT_Glyph_To_Bitmap (&image, ft_render_mode_normal, 0, 1);
if (err)
{
+ if (tmpstr)
+ gdFree (tmpstr);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem rendering glyph";