fixed a crash on invalid code

make sure we actually have some code modification,
otherwise, return an error code