Disallow casting between cstring and []u8

This commit is contained in:
gingerBill
2018-12-14 21:58:12 +00:00
parent d29335ecec
commit 9d6666f333
3 changed files with 17 additions and 5 deletions

View File

@@ -1926,11 +1926,11 @@ bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) {
return true;
}
// []byte/[]u8 <-> string
if (is_type_u8_slice(src) && is_type_string(dst)) {
// []byte/[]u8 <-> string (not cstring)
if (is_type_u8_slice(src) && (is_type_string(dst) && !is_type_cstring(dst))) {
return true;
}
if (is_type_string(src) && is_type_u8_slice(dst)) {
if ((is_type_string(src) && !is_type_cstring(src)) && is_type_u8_slice(dst)) {
// if (is_type_typed(src)) {
return true;
// }