[corlib] Add overflow checks to functions that alloc memory and uses raw pointers.