Commit 8367aba
authored
[rtext] Fix GetCodepointNext() to return default value on invalid input with size=0 (#2997)
* Fix GetCodepointNext to return default value with size=0 on invalid input. Modify LoadCodepoints to work when GetCodepointNext returns a size of 0. All internal use of GetCodepointNext and GetCodepointPrev checked. This fix may break external code dealing with invalid input as the old code erroneously never returned a size of 0, external code that doesn't properly check for size=0 may endlessly loop or overflow a buffer on invalid input.
* Change default behaviour of GetCodepointNext to return a size of 1 instead of 0. This matches existing prod behaviour and guarantees size 1..4 is returned. Simplify internal code that uses GetCodepointNext that previously had to account for size=0.
* Simplified progressing through a UTF-8 string in ImageTextEx and MeasureTextEx. This change matches existing precedent in DrawTextEx
* GetCodepointNext: Add 10xxxxxx checks to multibyte encodings.
---------
Co-authored-by: anon <anon>1 parent 17c443e commit 8367aba
2 files changed
+10
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1071 | 1071 | | |
1072 | 1072 | | |
1073 | 1073 | | |
1074 | | - | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | 1074 | | |
1079 | 1075 | | |
1080 | 1076 | | |
| |||
1205 | 1201 | | |
1206 | 1202 | | |
1207 | 1203 | | |
1208 | | - | |
| 1204 | + | |
1209 | 1205 | | |
1210 | 1206 | | |
1211 | 1207 | | |
1212 | 1208 | | |
1213 | 1209 | | |
1214 | 1210 | | |
1215 | 1211 | | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
| 1212 | + | |
1220 | 1213 | | |
1221 | 1214 | | |
1222 | 1215 | | |
| |||
1734 | 1727 | | |
1735 | 1728 | | |
1736 | 1729 | | |
1737 | | - | |
1738 | | - | |
| 1730 | + | |
1739 | 1731 | | |
1740 | 1732 | | |
1741 | 1733 | | |
| |||
1896 | 1888 | | |
1897 | 1889 | | |
1898 | 1890 | | |
1899 | | - | |
| 1891 | + | |
1900 | 1892 | | |
1901 | 1893 | | |
1902 | 1894 | | |
1903 | 1895 | | |
1904 | 1896 | | |
| 1897 | + | |
1905 | 1898 | | |
1906 | 1899 | | |
1907 | 1900 | | |
1908 | 1901 | | |
1909 | 1902 | | |
1910 | 1903 | | |
| 1904 | + | |
1911 | 1905 | | |
1912 | 1906 | | |
1913 | 1907 | | |
1914 | 1908 | | |
1915 | 1909 | | |
1916 | 1910 | | |
| 1911 | + | |
1917 | 1912 | | |
1918 | 1913 | | |
1919 | 1914 | | |
1920 | | - | |
| 1915 | + | |
1921 | 1916 | | |
1922 | 1917 | | |
1923 | 1918 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1266 | 1266 | | |
1267 | 1267 | | |
1268 | 1268 | | |
1269 | | - | |
| 1269 | + | |
1270 | 1270 | | |
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
1274 | 1274 | | |
1275 | 1275 | | |
1276 | | - | |
1277 | | - | |
1278 | | - | |
1279 | | - | |
1280 | 1276 | | |
1281 | 1277 | | |
1282 | 1278 | | |
| |||
1296 | 1292 | | |
1297 | 1293 | | |
1298 | 1294 | | |
1299 | | - | |
| 1295 | + | |
1300 | 1296 | | |
1301 | 1297 | | |
1302 | 1298 | | |
| |||
0 commit comments