Fix a memory corruption bug that wasted all my morning.