diff options
| author | Matthew Collins <[email protected]> | 2018-06-26 19:54:56 +0100 |
|---|---|---|
| committer | Matthew Collins <[email protected]> | 2018-06-26 19:55:21 +0100 |
| commit | 6d94bd0cd0b57b4e8ea87ed4e8d30c4d6a9bd3b8 (patch) | |
| tree | 79964281d2dd631398da98d7a4a579ad33c425da | |
| parent | Improve the generated wrappers (diff) | |
| download | steamworks-rs-6d94bd0cd0b57b4e8ea87ed4e8d30c4d6a9bd3b8.tar.xz steamworks-rs-6d94bd0cd0b57b4e8ea87ed4e8d30c4d6a9bd3b8.zip | |
Fix a crash requesting friends when the user is offline
| -rw-r--r-- | src/friends.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/friends.rs b/src/friends.rs index 68cbe6d..2604fa6 100644 --- a/src/friends.rs +++ b/src/friends.rs @@ -65,6 +65,9 @@ impl <Manager> Friends<Manager> { pub fn get_friends(&self, flags: FriendFlags) -> Vec<Friend<Manager>> { unsafe { let count = sys::SteamAPI_ISteamFriends_GetFriendCount(self.friends, flags.bits() as _); + if count == -1 { + return Vec::new(); + } let mut friends = Vec::with_capacity(count as usize); for idx in 0 .. count { let friend = SteamId(sys::SteamAPI_ISteamFriends_GetFriendByIndex(self.friends, idx, flags.bits() as _)); |