def fix_errors(config, validation):
    """Replace errors with their default values

    :param config: a validated ConfigObj to fix
    :type config: ConfigObj
    :param validation: the resuts of the validation
    :type validation: ConfigObj
    :returns: The altered config (does alter it in place though)
    :raises: None
    """
    for e in flatten_errors(config, validation):
        sections, key, err = e
        sec = config
        for section in sections:
            sec = sec[section]
        if key is not None:
            sec[key] = sec.default_values.get(key, sec[key])
        else:
            sec.walk(set_to_default)
    return config