I'll leave this, but something to think about. This style of defensive programming is a style I don't prefer myself. All the calls to copyToNewBuffer are within our control and I believe the situation that bufferToCopy is NULL is true can never happen. So, this line can be safely deleted. If not, it would need to be covered by a test.

If you test-drive your code, you should not have these lines, which traditionally developers would always add.

(Unless I'm wrong that it can't happen, I didn't check THAT carefully, but I think it won't be possible)