regedit: Fix potential buffer leak, simplify error handling (Coverity).