fix a potential leak in auto-completions function