Hybrid hardware-software method to enhance computer memory safety