Even if a defendant is guilty of some offense it often is not the offense that the State charged him with. This article is an example of successfully addressing this issue on appeal.

http://www.npr.org/sections/itsallpolitics/2015/05/13/406252639/imprisoned-nuclear-activist-nun-granted-victory-on-appeal#