writer: fix off-by-one error in assertion

* src/abg-writer.cc (write_array_subrange_type): Fix off-by-one
	error in assertion.
	* src/abg-dwarf-reader.cc (build_subrange_type): Assert the length
	of the array complies with its bounds.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2020-11-27 20:51:45 +01:00
parent 0a5f056393
commit bbdf7e0f29
2 changed files with 6 additions and 1 deletions

View File

@ -14889,6 +14889,11 @@ build_subrange_type(read_context& ctxt,
if (underlying_type)
result->set_underlying_type(underlying_type);
ABG_ASSERT(result->is_infinite()
|| (result->get_length() ==
(uint64_t) (result->get_upper_bound()
- result->get_lower_bound() + 1)));
if (associate_type_to_die)
ctxt.associate_die_to_type(die, result, where_offset);

View File

@ -2788,7 +2788,7 @@ write_array_subrange_type(const array_type_def::subrange_sptr& decl,
ABG_ASSERT(decl->is_infinite()
|| (decl->get_length() ==
(uint64_t) (decl->get_upper_bound()
- decl->get_lower_bound())));
- decl->get_lower_bound() + 1)));
o << " lower-bound='" << decl->get_lower_bound() << "' upper-bound='"
<< decl->get_upper_bound() << "'";
}