diff --git a/demos/fuzzer_builtin/main.tscn b/demos/fuzzer_builtin/main.tscn index 21b4c83..0461c5a 100644 --- a/demos/fuzzer_builtin/main.tscn +++ b/demos/fuzzer_builtin/main.tscn @@ -660,7 +660,7 @@ func _fuzz_tlattributedshapedstring(): if randi() % 3 == 0: str1.set_base_font(_fuzz_tlfontfamily()) else: - str1.set_base_font(nt_fam_full[randi() % (nt_fam_full.size() - 1)]) + str1.set_base_font(nt_fam_full) str1.get_base_font(); if randi() % 3 == 0: @@ -787,7 +787,7 @@ func _fuzz_tlshapedstring(): if randi() % 3 == 0: str1.set_base_font(_fuzz_tlfontfamily()) else: - str1.set_base_font(nt_fam_full[randi() % (nt_fam_full.size() - 1)]) + str1.set_base_font(nt_fam_full) str1.get_base_font(); if randi() % 3 == 0: diff --git a/demos/fuzzer_gdnative/main.tscn b/demos/fuzzer_gdnative/main.tscn index 4293104..090be14 100644 --- a/demos/fuzzer_gdnative/main.tscn +++ b/demos/fuzzer_gdnative/main.tscn @@ -611,7 +611,7 @@ func _fuzz_tlattributedshapedstring(): if randi() % 6 == 0: str1.add_attribute(randi() % RANGE - RANGE / 2, _randintarray(), randi() % RANGE - RANGE / 2, randi() % RANGE - RANGE / 2) if randi() % 2 == 0: - str1.add_attribute(TLConstants.TEXT_ATTRIBUTE_FONT, _fuzz_tlfontfamily(), randi() % RANGE - RANGE / 2, randi() % RANGE - RANGE / 2) + str1.add_attribute(1, _fuzz_tlfontfamily(), randi() % RANGE - RANGE / 2, randi() % RANGE - RANGE / 2) if randi() % 3 == 0: str1.remove_attribute(randi() % RANGE - RANGE / 2, randi() % RANGE - RANGE / 2, randi() % RANGE - RANGE / 2) str1.has_attribute(randi() % RANGE - RANGE / 2, randi() % RANGE - RANGE / 2) @@ -669,7 +669,7 @@ func _fuzz_tlattributedshapedstring(): if randi() % 3 == 0: str1.set_base_font(_fuzz_tlfontfamily()) else: - str1.set_base_font(nt_fam_full[randi() % (nt_fam_full.size() - 1)]) + str1.set_base_font(nt_fam_full) str1.get_base_font(); if randi() % 3 == 0: @@ -796,7 +796,7 @@ func _fuzz_tlshapedstring(): if randi() % 3 == 0: str1.set_base_font(_fuzz_tlfontfamily()) else: - str1.set_base_font(nt_fam_full[randi() % (nt_fam_full.size() - 1)]) + str1.set_base_font(nt_fam_full) str1.get_base_font(); if randi() % 3 == 0: diff --git a/src/resources/tl_shaped_attributed_string.cpp b/src/resources/tl_shaped_attributed_string.cpp index 49a63c4..c8b893a 100644 --- a/src/resources/tl_shaped_attributed_string.cpp +++ b/src/resources/tl_shaped_attributed_string.cpp @@ -1279,14 +1279,14 @@ int64_t TLShapedAttributedString::get_attribute_start(int64_t p_attribute, int64 } if (p_attribute <= TEXT_ATTRIBUTE_MAX_FORMAT_ATTRIBUTE) { auto attrib = format_attributes.find_closest(p_index); - if (attrib) { + if (!attrib) { ERR_PRINTS("Attribute not set"); ERR_FAIL_COND_V(true, -1); } return attrib->key(); } else { auto attrib = style_attributes.find_closest(p_index); - if (attrib) { + if (!attrib) { ERR_PRINTS("Attribute not set"); ERR_FAIL_COND_V(true, -1); } @@ -1302,16 +1302,24 @@ int64_t TLShapedAttributedString::get_attribute_end(int64_t p_attribute, int64_t } if (p_attribute <= TEXT_ATTRIBUTE_MAX_FORMAT_ATTRIBUTE) { auto attrib = format_attributes.find_closest(p_index); + if (!attrib) { + ERR_PRINTS("Attribute not set"); + ERR_FAIL_COND_V(true, -1); + } attrib = attrib->next(); - if (attrib) { + if (!attrib) { ERR_PRINTS("Attribute not set"); ERR_FAIL_COND_V(true, -1); } return attrib->key(); } else { auto attrib = style_attributes.find_closest(p_index); + if (!attrib) { + ERR_PRINTS("Attribute not set"); + ERR_FAIL_COND_V(true, -1); + } attrib = attrib->next(); - if (attrib) { + if (!attrib) { ERR_PRINTS("Attribute not set"); ERR_FAIL_COND_V(true, -1); }