Commits

Anonymous committed e72c900

fixed memory leaks through failure

  • Participants
  • Parent commits f961de9
  • Branches GD-2.0

Comments (0)

Files changed (1)

   else
     {
       /* No character set found! */
+      gdCacheDelete (tc_cache);
       gdMutexUnlock (gdFontCacheMutex);
       return "No character set found";
     }
 			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;
 	  } 
 		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 ",
       err = FT_Load_Glyph (face, glyph_index, render_mode);
       if (err)
 	{
+	  if (tmpstr)
+	    gdFree (tmpstr);
 	  gdCacheDelete (tc_cache);
 	  gdMutexUnlock (gdFontCacheMutex);
 	  return "Problem loading glyph";
           err = FT_Load_Glyph (face, glyph_index, render_mode);
           if (err)
 	    {
+	      if (tmpstr)
+	        gdFree (tmpstr);
 	      gdCacheDelete (tc_cache);
 	      gdMutexUnlock (gdFontCacheMutex);
 	      return "Problem loading glyph";
 	      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";