Don't over-read memory returned by _DTOA_R, and never write to it since the result might be a string literal. For example, when doing: swprintf(tt, 20, L"%.*f", 6, 0.0); we will get back "0". Instead, write the result returned by _DTOA_R to the output buffer. After this, write the 0 chars directly to the the output buffer (if there are any). This also has the (marginal) advantage that we read/write less memory overall. The patch, contributed by Silviu Baranga was tested against libcxx testsuite and showed no regression. Please find the patch in git format-patch format in attachment. Best regards, Thomas