afc_file_open: fixed memory leak when the object is not found or arguments are invalid.