The bigger issue I see is the low quality police work.
Back "in the day" it wasn't uncommon for US police to frame random black guys for crimes in order to consider the crime solved. Sticking a homeless guy in prison over something that's a natural right in other parts of the world and in the presence of substantial doubt that it was even his (plausible other reasons for his DNA to be on the gun and no motive to have it in the first place) seems to be about the same level of quality.