Skip to content

Commit

Permalink
Update fuzzer projects, more fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed Nov 1, 2019
1 parent 49fb8eb commit bea7af6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions demos/fuzzer_builtin/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions demos/fuzzer_gdnative/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 12 additions & 4 deletions src/resources/tl_shaped_attributed_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit bea7af6

Please sign in to comment.