I'm not completely sure how it works for prisoners who were homeless, but normally for homeless people, there are a few different ways to determine which ridings they're eligible to vote in.Do you know what happens to those of 'no fixed abode'?
For instance, shelters are provided with Elections Canada forms that they can give to people who regularly stay there, which the person can bring to the polls so they can use the shelter as their declared place of residence.
A homeless person can also make an official declaration about the area where they generally live... though this has to be witnessed by someone who knows them and can confirm that the declaration is true, so I don't know how it works when someone's making this declaration while in prison.