Fix memory boundary checking

Legal access : addr+len<=mem_size;
Illegal access : addr+len>mem_size;
Merge pull request #85 from mzguanglin/bugfixes

Fix memory boundary checking