Fix memory boundary checking

Legal access : addr+len<=mem_size;
Illegal access : addr+len>mem_size;