update the memcopy and memset checks to address potential overflow issues