fix crash when read fails