Commit cd945c2
committed
Test: fix Esc(wchar_t) crash under _FORTIFY_SOURCE=3
Cygwin's snprintf returns -1 for %lc with wide chars that are not
representable in the C locale, even when iswprint() reports them as
printable (e.g., U+FFFD). Under NDEBUG (Release/RelWithDebInfo),
the assert(n > 0) is compiled away, and std::string(buf, SIZE_MAX)
throws std::length_error.
Always use hex representation for wchar_t in Esc(), avoiding the
platform-specific %lc divergence entirely.1 parent 8a9409a commit cd945c2
1 file changed
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| |||
0 commit comments