Fix coverity issues in r_util