mirror of
https://github.com/irmen/prog8.git
synced 2025-02-28 09:29:26 +00:00
add warning when encoded string contains 0-byte
This commit is contained in:
parent
c58b8a4973
commit
6fcb51cea2
@ -794,7 +794,9 @@ internal class AstChecker(private val program: Program,
|
|||||||
checkValueTypeAndRangeString(DataType.STR, string)
|
checkValueTypeAndRangeString(DataType.STR, string)
|
||||||
|
|
||||||
try { // just *try* if it can be encoded, don't actually do it
|
try { // just *try* if it can be encoded, don't actually do it
|
||||||
compilerOptions.compTarget.encodeString(string.value, string.altEncoding)
|
val bytes = compilerOptions.compTarget.encodeString(string.value, string.altEncoding)
|
||||||
|
if(0u in bytes)
|
||||||
|
errors.warn("a character in the string encodes into the 0-byte, which will terminate the string prematurely", string.position)
|
||||||
} catch (cx: CharConversionException) {
|
} catch (cx: CharConversionException) {
|
||||||
errors.err(cx.message ?: "can't encode string", string.position)
|
errors.err(cx.message ?: "can't encode string", string.position)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user