A prosecution is not a bar if: (1) the former prosecution was before a court that lacked jurisdiction over the defendant or the offense; or (2) the former prosecution resulted in a judgment of conviction that was held invalid in a postconviction hearing.