Brazil’s ex-president could be freed after court ruling