mem: fix UB in readInt/writeInt and delete variants
#17802
Merged
readInt/writeInt and delete variants
#17802