Might be a slight issue here - if strlen(cPtr) > iBufferSize then enough memory won't be allocated.