Skip to content

Commit

Permalink
return error on empty header
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarnadas committed Jul 27, 2021
1 parent 8508076 commit f533b2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/course2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ impl Course2 {
};

let header = Course2::get_course_header(&data)?;
if let Some(header) = &header.as_ref() {
if header.title.is_empty() {
return Err(Error::Smm2Error(Smm2Error::HeaderDataEmpty));
}
}
let course_area = Course2::get_course_area(&data, 0)?;
let course_sub_area = Course2::get_course_area(&data, 1)?;

Expand Down
2 changes: 2 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ pub enum Smm2Error {
ConvertFromBuffer,
#[error("String too long. Expected max length <= 75. Receiced: {0}")]
StringTooLong(usize),
#[error("Header data seems to be empty")]
HeaderDataEmpty,
}

#[cfg(feature = "save")]
Expand Down

0 comments on commit f533b2a

Please sign in to comment.