@@ -912,6 +912,13 @@ lxb_encoding_decode_iso_2022_jp(lxb_encoding_decode_t *ctx,
912912 }
913913 LXB_ENCODING_DECODE_ERROR_END ();
914914
915+ if (ctx -> buffer_used >= ctx -> buffer_length ) {
916+ iso -> prepand = iso -> lead ;
917+ iso -> lead = 0x00 ;
918+
919+ return LXB_STATUS_SMALL_BUFFER ;
920+ }
921+
915922 byte = iso -> lead ;
916923 iso -> lead = 0x00 ;
917924
@@ -1279,6 +1286,12 @@ lxb_encoding_decode_utf_16(lxb_encoding_decode_t *ctx, bool is_be,
12791286 }
12801287 LXB_ENCODING_DECODE_ERROR_END ();
12811288
1289+ if (ctx -> buffer_used >= ctx -> buffer_length ) {
1290+ ctx -> u .lead = lead + 0x01 ;
1291+
1292+ return LXB_STATUS_SMALL_BUFFER ;
1293+ }
1294+
12821295 goto lead_state ;
12831296 }
12841297
@@ -1723,6 +1736,13 @@ lxb_encoding_decode_gb18030(lxb_encoding_decode_t *ctx,
17231736 }
17241737 LXB_ENCODING_DECODE_ERROR_END ();
17251738
1739+ if (ctx -> buffer_used >= ctx -> buffer_length ) {
1740+ ctx -> prepend = true;
1741+ ctx -> u .gb18030 .first = second ;
1742+
1743+ return LXB_STATUS_SMALL_BUFFER ;
1744+ }
1745+
17261746 first = second ;
17271747
17281748 goto prepend_first ;
@@ -1756,11 +1776,8 @@ lxb_encoding_decode_gb18030(lxb_encoding_decode_t *ctx,
17561776 }
17571777 LXB_ENCODING_DECODE_ERROR_END ();
17581778
1759- LXB_ENCODING_DECODE_APPEND_WO_CHECK (ctx , second );
1760-
1761- if (ctx -> buffer_used == ctx -> buffer_length ) {
1779+ if (ctx -> buffer_used >= ctx -> buffer_length ) {
17621780 ctx -> prepend = true;
1763- ctx -> have_error = true;
17641781
17651782 /* First is a fake for trigger */
17661783 ctx -> u .gb18030 .first = 0x01 ;
@@ -1770,6 +1787,18 @@ lxb_encoding_decode_gb18030(lxb_encoding_decode_t *ctx,
17701787 return LXB_STATUS_SMALL_BUFFER ;
17711788 }
17721789
1790+ LXB_ENCODING_DECODE_APPEND_WO_CHECK (ctx , second );
1791+
1792+ if (ctx -> buffer_used >= ctx -> buffer_length ) {
1793+ ctx -> prepend = true;
1794+
1795+ ctx -> u .gb18030 .first = third ;
1796+ ctx -> u .gb18030 .second = 0x00 ;
1797+ ctx -> u .gb18030 .third = 0x00 ;
1798+
1799+ return LXB_STATUS_SMALL_BUFFER ;
1800+ }
1801+
17731802 first = third ;
17741803
17751804 goto prepend_first ;
0 commit comments