Fix memory stomp due to incorrect malloc size.

In a release build this code would often function without noticable issues, but could cause random issues elsewhere.