fixed pointer bug. This could result in an illegal memory access when th...

Fixed a pointer bug. Results in out of bound memory accesses if the input count is smaller then the output count.