From 96c3d98256c2f5a8ebb281024fa57bf33ba5acbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 8 Oct 2020 15:37:19 +0200 Subject: [PATCH] Userid: fix borrow/deref recursion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit not triggered by any current code, but this would lead to a stack exhaustion since borrow would call deref which would call borrow again.. Signed-off-by: Fabian Grünbichler --- src/api2/types/userid.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api2/types/userid.rs b/src/api2/types/userid.rs index f0a61031..44cd10b7 100644 --- a/src/api2/types/userid.rs +++ b/src/api2/types/userid.rs @@ -131,13 +131,13 @@ impl std::ops::Deref for Username { impl Borrow for Username { fn borrow(&self) -> &UsernameRef { - UsernameRef::new(self.as_str()) + UsernameRef::new(self.0.as_str()) } } impl AsRef for Username { fn as_ref(&self) -> &UsernameRef { - UsernameRef::new(self.as_str()) + self.borrow() } } @@ -204,13 +204,13 @@ impl std::ops::Deref for Realm { impl Borrow for Realm { fn borrow(&self) -> &RealmRef { - RealmRef::new(self.as_str()) + RealmRef::new(self.0.as_str()) } } impl AsRef for Realm { fn as_ref(&self) -> &RealmRef { - RealmRef::new(self.as_str()) + self.borrow() } }