Fixed some memory issues

 * invalid pointer, uninitialized buffer