Skip to content

Conversation

akshat62
Copy link
Contributor

@akshat62 akshat62 commented Jun 28, 2025

@akshat62 akshat62 closed this Jun 28, 2025
}
wcsncpy(buf, wbuf, buflen);
wcsncpy(buf, wbuf, buflen - 1);
buf[buflen - 1] = L'\0'; /* Ensure null termination */
Copy link
Member

@picnixz picnixz Jun 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, it's not necessary because wcsncpy copies the NUL termination if it's counted in buflen (which is the case because buflen > r1 == len(buf_without_NUL). And wcsncpy just fills the remaining chars with NUL chars:

If, after copying the terminating null wide character from src, count is not reached, additional null wide characters are written to dest until the total of count characters have been written.

So we'll anyway have a NUL termination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants