From f533b2a0ecdbe4ebc763c1d9eb0abf1d5b541e7d Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Tue, 27 Jul 2021 06:36:39 +0200 Subject: [PATCH] return error on empty header --- src/course2.rs | 5 +++++ src/errors.rs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/course2.rs b/src/course2.rs index bb1910a..951b1d5 100644 --- a/src/course2.rs +++ b/src/course2.rs @@ -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)?; diff --git a/src/errors.rs b/src/errors.rs index 4b8f8cb..cab7c2d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -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")]