As long as they did not cancel your RP, you are not illegal here. You can negotiate to your previous employer not to cancel you until your RP is finish and they will release you so your new employer can renew your RP under their sponsorship. You can talk to both so you can have peace of mind. :-)