Improve the safety check used in fetch.c