Skip to content

Commit 0a6ea5b

Browse files
committed
Fix legacy text conversion filter for UCS-4
If a downstream filter returns -1 (error), the CK macro will make the UCS-4 conversion filter also immediately return. This means that any necessary updates to the filter state have to be done *before* using CK, or it will be left in an invalid state and will not behave correctly when flushed.
1 parent 44b4fb2 commit 0a6ea5b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/mbstring/libmbfl/filters/mbfilter_ucs4.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ int mbfl_filt_conv_ucs4_wchar(int c, mbfl_convert_filter *filter)
191191
n = c & 0xff;
192192
}
193193
n |= filter->cache;
194+
filter->status &= ~0xff;
194195
if ((n & 0xffff) == 0 && ((n >> 16) & 0xffff) == 0xfffe) {
195196
if (endian) {
196197
filter->status = 0; /* big-endian */
@@ -200,7 +201,6 @@ int mbfl_filt_conv_ucs4_wchar(int c, mbfl_convert_filter *filter)
200201
} else if (n != 0xfeff) {
201202
CK((*filter->output_function)(n, filter->data));
202203
}
203-
filter->status &= ~0xff;
204204
break;
205205
}
206206

0 commit comments

Comments
 (0)