Fix memory leaks in get_toolkit_name and get_toolkit_version