Index: src/keymap.c
===================================================================
--- src/keymap.c	(revision 2365)
+++ src/keymap.c	(working copy)
@@ -1165,12 +1165,12 @@ _vte_keymap_map(guint keyval,
 		}
 	}
 	if (termcap_special != NULL) {
-		tmp = g_strdup(terminal);
 		cap = NULL;
-		if (tgetent(ncurses_buffer, tmp) == 1) {
+		if (tgetent(ncurses_buffer, terminal) == 1) {
 			cap = ncurses_area;
 			tmp = g_strdup(termcap_special);
 			cap = tgetstr(tmp, &cap);
+			g_free(tmp);
 		}
 		if ((cap == NULL) && (strstr(terminal, "xterm") != NULL)) {
 			/* try, try again */
@@ -1178,9 +1178,9 @@ _vte_keymap_map(guint keyval,
 				cap = ncurses_area;
 				tmp = g_strdup(termcap_special);
 				cap = tgetstr(tmp, &cap);
+				g_free(tmp);
 			}
 		}
-		g_free(tmp);
 		if ((cap != NULL) && (*cap != '\0')) {
 			*normal_length = strlen(cap);
 			*normal = g_strdup(cap);
