NFC: Fix invalid access to an empty text record.

pull/7822/head
Vincent Coubard 2018-08-28 17:45:51 +01:00
parent 9a3b64bd55
commit 0fa481ace6
1 changed files with 8 additions and 0 deletions

View File

@ -118,6 +118,10 @@ Span<const uint8_t> Text::get_language_code() const
Span<const uint8_t> Text::get_text() const Span<const uint8_t> Text::get_text() const
{ {
if (!_text_record) {
return Span<const uint8_t>();
}
size_t language_code_size = get_language_code().size(); size_t language_code_size = get_language_code().size();
return make_const_Span( return make_const_Span(
@ -138,6 +142,10 @@ bool Text::append_as_record(
bool is_last_record bool is_last_record
) const ) const
{ {
if (!_text_record) {
return false;
}
// Build the record type // Build the record type
RecordType type( RecordType type(
RecordType::well_known_type, RecordType::well_known_type,