Index: vte/src/vtexft.c
===================================================================
--- vte.orig/src/vtexft.c	2008-06-22 09:20:08.000000000 -0700
+++ vte/src/vtexft.c	2008-06-22 10:49:22.000000000 -0700
@@ -165,8 +165,6 @@
 	font->patterns = patterns;
 	font->last_pattern = 0;
 	font->have_metrics = FALSE;
-	font->locked_fonts[0] = ptr_array_zeroed_new (1 + font->patterns->len);
-	font->locked_fonts[1] = ptr_array_zeroed_new (1 + font->patterns->len);
 
 	if (font_cache == NULL) {
 		font_cache = g_hash_table_new (
@@ -189,12 +187,39 @@
 		g_ptr_array_add (font->fonts, NULL); /* 1 indexed array */
 		font->fontmap = _vte_tree_new (_vte_xft_direct_compare);
 		font->widths = _vte_tree_new (_vte_xft_direct_compare);
+		font->locked_fonts[0] = ptr_array_zeroed_new (
+						1 + font->patterns->len);
+		font->locked_fonts[1] = ptr_array_zeroed_new (
+						1 + font->patterns->len);
 	}
 
 	return font;
 }
 
 static void
+_vte_xft_unlock_font (struct _vte_xft_font *font, guint element, gboolean free_array)
+{
+	guint j, i;
+	i = element & 1;
+
+	if (font->locked_fonts[i] != NULL) {
+		for (j = 1; j < font->locked_fonts[i]->len; j++) {
+			XftFont *ftfont = g_ptr_array_index (
+					font->locked_fonts[i], j);
+			if (ftfont != NULL) {
+				XftUnlockFace (ftfont);
+				g_ptr_array_index (
+					font->locked_fonts[i], j) = NULL;
+			}
+		}
+		if (free_array) {
+			g_ptr_array_free (font->locked_fonts[i], TRUE);
+			font->locked_fonts[i] = NULL;
+		}
+	}
+}
+
+static void
 _vte_xft_font_close (struct _vte_xft_font *font)
 {
 	XftFont *ftfont;
@@ -203,6 +228,11 @@
 	if (--font->ref) {
 		return;
 	}
+
+	for (i = 0; i < G_N_ELEMENTS (font->locked_fonts); i++) {
+		_vte_xft_unlock_font (font, i, TRUE);
+	}
+
 	g_hash_table_remove (font_cache, font);
 
 	for (i = 0; i < font->patterns->len; i++) {
@@ -373,45 +403,16 @@
 }
 
 static void
-_vte_xft_unlock_font (struct _vte_xft_font *font, guint element, gboolean free_array)
-{
-	guint j, i;
-	i = element & 1;
-
-	if (font->locked_fonts[i] != NULL) {
-		for (j = 1; j < font->locked_fonts[i]->len; j++) {
-			XftFont *ftfont = g_ptr_array_index (
-					font->locked_fonts[i], j);
-			if (ftfont != NULL) {
-				XftUnlockFace (ftfont);
-				g_ptr_array_index (
-					font->locked_fonts[i], j) = NULL;
-			}
-		}
-		if (free_array) {
-			g_ptr_array_free (font->locked_fonts[i], TRUE);
-			font->locked_fonts[i] = NULL;
-		}
-	}
-}
-
-static void
-_vte_xft_unlock_fonts (struct _vte_xft_font *font)
-{
-	guint i;
-	for (i = 0; i < G_N_ELEMENTS (font->locked_fonts); i++) {
-		_vte_xft_unlock_font (font, i, TRUE);
-	}
-}
-static void
 _vte_xft_destroy (struct _vte_draw *draw)
 {
 	struct _vte_xft_data *data;
 	data = (struct _vte_xft_data*) draw->impl_data;
 	if (data->font != NULL) {
-		_vte_xft_unlock_fonts (data->font);
 		_vte_xft_font_close (data->font);
 	}
+	if (data->font_bold != NULL) {
+		_vte_xft_font_close (data->font_bold);
+	}
 	if (data->pixmap != NULL) {
 		g_object_unref (data->pixmap);
 	}
@@ -466,7 +467,17 @@
 	}
 	g_assert (data->display == data->font->display);
 
-	_vte_xft_unlock_font (data->font, ++data->font->cur_locked_fonts&1, FALSE);
+	_vte_xft_unlock_font (data->font,
+			      ++data->font->cur_locked_fonts&1,
+			      FALSE);
+
+	if (data->font_bold) {
+		g_assert (data->display == data->font_bold->display);
+
+		_vte_xft_unlock_font (data->font_bold,
+				      ++data->font_bold->cur_locked_fonts&1,
+				      FALSE);
+	}
 }
 
 static void
@@ -646,7 +657,6 @@
 	ft = _vte_xft_font_open (draw->widget, fontdesc, antialias);
 	if (ft != NULL) {
 		if (*fontptr != NULL) {
-			_vte_xft_unlock_fonts (*fontptr);
 			_vte_xft_font_close (*fontptr);
 		}
 		*fontptr = ft;
@@ -753,6 +763,7 @@
 		       const PangoFontDescription *fontdesc,
 		       VteTerminalAntiAlias antialias)
 {
+	PangoFontDescription *bolddesc;
 	struct _vte_xft_data *data;
 
 	data = (struct _vte_xft_data*) draw->impl_data;
@@ -764,8 +775,7 @@
 	}
 
 	/* calculate bold font desc */
-	PangoFontDescription *bolddesc = pango_font_description_copy (fontdesc);
-	if (!bolddesc) {
+	if ( !(bolddesc = pango_font_description_copy (fontdesc)) ) {
 		goto boldless;
 	}
 	pango_font_description_set_weight (bolddesc, PANGO_WEIGHT_BOLD);
