Menu

#335 fix multiple bugs in CGUIStaticText::breakText()

closed-fixed
None
5
2026-06-25
2026-06-08
Mercury233
No

Left-to-Right:

  • Added bounds checking when parsing \r to prevent out-of-bounds array access.
  • Fixed the Soft Hyphen (0x00AD) substring logic so the control character is no longer incorrectly prepended to the next line.
  • Prevented null characters (\0) from being erroneously appended to whitespace strings.

Right-to-Left:

  • Fixed an initial out-of-bounds read by changing the loop start from size to size - 1.
  • Corrected the reverse-parsing logic for Windows newlines (\r\n) and properly adjusted the iterator after Text.erase() to prevent skipping characters.
  • Fixed the very first character of the text (i == 0) was wrongly truncated from the output.
  • Added isWhitespace variable for consistent logic with LTR path.
1 Attachments

Discussion

  • Michael Zeilfelder

    • status: open --> closed-fixed
    • assigned_to: Michael Zeilfelder
     
  • Michael Zeilfelder

    Thanks for your patch and sorry I didn't find time&energy so long to apply it. It's now in svn #r6830 with some minor changes : First bounds-check shouldn't be needed as string always has 0 behind size (thought it also wouldn't hurt to test I guess). Not splitting anymore if soft hyphen is first character (would just add empty line). Some variable renaming to avoid confused IDE's

     
  • Mercury233

    Mercury233 - 2026-06-25

    findNext returns -1 on not found, so I guess it should be if (idxHyphen > 0)

     
  • Michael Zeilfelder

    Ah thanks a lot! Yeah, back to != -1 or > 0 certainly (rewrote it different first, etc... stupid bug, guess I'm still too tired for doing patches).

     

Log in to post a comment.

Auth0 Logo