From c2d6e6ca917c8a0e129f0eec436cf9b35b4d1051 Mon Sep 17 00:00:00 2001 From: Quang Tran Date: Wed, 9 Oct 2024 16:40:40 +0700 Subject: [PATCH] Fixed crash when it tried to remove the first element in case its array is empty --- RMQClient/RMQMultipleChannelAllocator.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RMQClient/RMQMultipleChannelAllocator.m b/RMQClient/RMQMultipleChannelAllocator.m index 8980d742..e380e994 100644 --- a/RMQClient/RMQMultipleChannelAllocator.m +++ b/RMQClient/RMQMultipleChannelAllocator.m @@ -105,7 +105,9 @@ - (void)releaseChannelNumber:(NSNumber *)channelNumber { - (NSArray *)allocatedUserChannels { NSMutableArray *userChannels = [self.channels.allValues mutableCopy]; - [userChannels removeObjectAtIndex:0]; + if ([userChannels count] > 0) { + [userChannels removeObjectAtIndex:0]; + } return [userChannels sortedArrayUsingComparator:^NSComparisonResult(id ch1, id ch2) { return ch1.channelNumber.integerValue > ch2.channelNumber.integerValue; }];