Repository navigation
text-freetype2: Decode UTF-16 through UTF-8 and bound tail scan - #8
chriscoveries wants to merge 1 commit into
Conversation
UTF-16 file bytes were fread straight into a wchar_t buffer: on Linux/macOS wchar_t is 4 bytes, so the bytes never formed a NUL- terminated wide string and remove_cr/wcslen scanned out of bounds. read_from_end could also underflow cur_pos (uint32) below 0 on odd file sizes, wrapping the tail scan into an unbounded loop. - decode UTF-16LE (with surrogate pairs) to UTF-8, then reuse the existing os_utf8_to_wcs path for a proper wchar_t string - clamp the utf16 tail-scan decrement at 0 instead of wrapping - skip the BOM when the scan reaches the start of the file Fixes obs-rust#95
12d6c19 to
8db8f86
Compare
|
Source review of 8db8f86 against fork-held integration c2d617e; no local build, reproduction or CI claim. Keep #8 as the single UTF-16 loading/tail-selection concern. It is not redundant: this head decodes UTF-16LE through UTF-8 into wchar_t:370–427, while the integration baseline still reads UTF-16 bytes directly into wchar_t storage:421–433. The tail underflow/BOM corrections are also unique. Refresh only this production-file delta onto the chosen current base, preserving the baseline's glyph-atlas work rather than carrying unrelated history. One small source gap belongs in that refresh: cur_pos starts at unaligned filesize:505–533. With an odd trailing byte, stepping backwards by two reads misaligned UTF-16 pairs and misses real newlines. Source-derived regression: BOM + “A\nB\nC”, log_lines=1, selects “B\nC”; appending one incomplete byte makes this loop select “A\nB\nC”. Align the scan to complete UTF-16 code units and apply an explicit trailing-incomplete-byte policy. The fix commit adds no tests. Preserve a RED/GREEN pair with BOM-only input, BMP text, a valid surrogate pair, malformed/truncated surrogates, correct wide-string termination, BOM exclusion and that odd-tail regression. Keep tail selection unchanged when an incomplete final code unit is ignored, and cover supported wchar_t widths. This is a focused refresh/test request, not a retirement candidate. |
8db8f86 to
aabba78
Compare
UTF-16 file bytes were
freadstraight into awchar_tbuffer: on Linux/macOSwchar_tis 4 bytes, so the data never formed a NUL-terminated wide string andremove_cr/wcslenscanned out of bounds.read_from_endalso underflowedcur_pos(uint32_t) below 0 on odd file sizes, wrapping the tail scan into an unbounded loop.os_utf8_to_wcspath sosrcdata->textis a properwchar_tstring everywhereFixes obs-rust#95