--- gedit-2.14.2.orig/gedit/gedit-commands-file.c
+++ gedit-2.14.2/gedit/gedit-commands-file.c
@@ -672,6 +672,7 @@
 {
 	gchar *uri;
 	gboolean ro;
+	GtkFileChooserConfirmation result;
 
 	gedit_debug (DEBUG_COMMANDS);
 
@@ -679,20 +680,21 @@
 
 	ro = is_read_only (uri);
 
-	g_free (uri);
-
 	if (ro)
 	{
 		if (replace_read_only_file (GTK_WINDOW (dialog), uri))
-			return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
+			result = GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
 		else
-			return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
+			result = GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
 	}
 	else
 	{
 		/* fall back to the default confirmation dialog */
-		return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM;
+		result = GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM;
 	}
+
+	g_free (uri);
+	return result;
 }
 
 static void
