Fixed incorrect size calculation which resulted in a buffer overflow.