fix: exit a function in case of ENOMEM