MHN
Add a comment on Hacker News →
1 of 118 comments
  1. wchar_t *value = (wchar_t *)malloc(length);

    // The documentation says that if the string for some reason was not stored with zero-termination, we need to manually terminate it. Sigh!

    if (value[length]) { value[length+1] = 0; }