Keats / jsonwebtoken

JWT lib in rust
MIT License
1.69k stars 271 forks source link

Stack overflow calling Error::to_string #118

Closed fujiapple852 closed 4 years ago

fujiapple852 commented 4 years ago

Invoking Error::to_string results in a stack overflow crash due to a recursive call in the Display::fmt implementation.

Example:

#[test]
fn test_error_rendering() {
    assert_eq!("InvalidAlgorithmName", Error::from(ErrorKind::InvalidAlgorithmName).to_string());
}

Results in:

thread 'errors::tests::test_error_rendering' has overflowed its stack
fatal runtime error: stack overflow

Simple fix in PR: https://github.com/Keats/jsonwebtoken/pull/117