Merge "Fix write past end of memory." into lmp-dev