When there's a warrant, even if wrongly granted, the arrest and imprisonment is considered lawful.
https://en.wikipedia.org/wiki/Habeas_corpus