What is this being safe with respect to?  What do the APIs being used do if the buffer is too small?