Fixed some crash for writing read-only memory.