Skip to content

Commit

Permalink
Fix out-of-bounds array access in locale.rs (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivacoNew authored Jan 12, 2025
2 parents 5d839de + 8906a29 commit e773c89
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ pub fn get_locale() -> Result<LocaleInfo, ModuleError> {
Err(e) => return Err(ModuleError::new("Locale", format!("Could not parse $LANG env variable: {}", e)))
};
let raw_split: Vec<&str> = raw.split('.').collect();
locale.language = raw_split[0].to_string();
locale.encoding = raw_split[1].to_string();
locale.language = raw_split.first().unwrap_or(&locale.language.as_ref()).to_string();
locale.encoding = raw_split.get(1).unwrap_or(&locale.encoding.as_ref()).to_string();

Ok(locale)
}

0 comments on commit e773c89

Please sign in to comment.