uci: refactor revert code to avoid illegal pointer access