Skip to content

Commit b27a34c

Browse files
committed
SJIS-mac encoding conversion: Stop the carnage of innocent Unicode codepoints
When converting Unicode to MacJapanese, some special sequences of Unicode codepoints are collapsed into a single SJIS character. When the implementation sees a codepoint which *might* begin such a sequence, it is cached and examined again after the next codepoint arrives. If it turns out that it wasn't one of the 'special' sequences, then a 'fallback' conversion table is consulted to convert the cached codepoint. Then we re-enter the regular conversion code to convert the immediately following codepoint. BUT, local variables need to be reinitialized properly when doing this! Because the locals weren't reinitialized, the sad result was that some codepoints would get chopped up into bit salad and emitted as something totally bogus (which might not even be valid SJIS-mac text at all).
1 parent 7f0e86b commit b27a34c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
372372
if (s2 <= 0 || s1 == -1) {
373373
break;
374374
}
375+
s1 = s2 = 0;
375376

376377
case 0:
377378

0 commit comments

Comments
 (0)