Hmm... how that works I wonder? I.e. somebody can be kept in the prison forever even if original sentence was, say, 10 years? How do you know if one is rehabilitated or not? It's not like criminal psychopath would have any problem telling whoever is in charge any words they want to hear and present as "sincere" picture of rehabilitation as he'd be required to get out.
And how keeping somebody in prison for 10 years is not punishment?