Skip to content

Fix setcchar() for an empty wide string - #389

Merged
Bill-Gray merged 1 commit into
Bill-Gray:masterfrom
serhiy-storchaka:fix-setcchar-empty
Sep 15, 2026
Merged

Bill-Gray merged 1 commit into
Bill-Gray:masterfrom
serhiy-storchaka:fix-setcchar-empty

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Contributor

_wchar_to_int32_array() stores only the terminating zero for an empty string, and the combining-character loop in setcchar() then read the uninitialised rest of the array. Bound the loop by the number of characters actually stored.

With the vt port under valgrind, setcchar(&cell, L"", A_NORMAL, 0, NULL) reported "Conditional jump or move depends on uninitialised value(s)" and produced 0x110001; it now produces 0 and valgrind is clean. A combining sequence such as L"é" still round-trips through getcchar().

Fixes #388.

The combining-character loop read past the terminating zero into the
uninitialised rest of the array.  Fixes Bill-Gray#388.

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Bill-Gray
Bill-Gray merged commit ba1cef6 into Bill-Gray:master Sep 15, 2026
4 checks passed
@Bill-Gray

Copy link
Copy Markdown
Owner

Looks good to me as well. Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setcchar() with an empty wide string reads uninitialised stack

3 participants