meganz / iOS

MEGA for iOS

Home Page:https://apps.apple.com/app/mega/id706857885?mt=8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blows up in chat view (array out of bounds)

sofqi opened this issue · comments

commented
�
[10-03 14:55:37][sdk] [iOS] onChatListItemUpdate <MEGAChatListItem: chatId=u3CCrFR6WqE, title=Shane, changes=Unread count, last message=😋, last date=2017-09-25 14:19:36 +0000, last type=Normal, own privilege=Moderator, unread=0, group=NO, active=YES> (MainTabBarController.m:151)
[10-03 14:55:37][sdk] [iOS] onChatRoomUpdate <MEGAChatRoom: chatId=u3CCrFR6WqE, title=Shane, own privilege=moderator, peer count=1, group=NO, changes=Unread count, unread=0, user typing=18446744073709551615, active=YES> (MessagesViewController.m:1352)
[10-03 14:55:37][sdk] [iOS] onMessageLoaded (null) (MessagesViewController.m:1244)
[10-03 14:55:37][sdk] [iOS] onMessageLoaded (null) (MessagesViewController.m:1244)
[10-03 14:55:38][sdk] [iOS] onChatListItemUpdate <MEGAChatListItem: chatId=u3CCrFR6WqE, title=Shane, changes=Last message, last message=😋, last date=2017-09-25 14:19:36 +0000, last type=Normal, own privilege=Moderator, unread=0, group=NO, active=YES> (ChatRoomsViewController.m:679)
2017-10-03 09:55:38.851136-0500 MEGA[95448:18201467] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM replaceObjectAtIndex:withObject:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010e7a91cb __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010d411f41 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010e7e8e8c _CFThrowFormattedException + 194
	3   CoreFoundation                      0x000000010e6ef69f -[__NSArrayM replaceObjectAtIndex:withObject:] + 319
	4   MEGA                                0x000000010b3af6b5 -[ChatRoomsViewController onChatListItemUpdate:item:] + 1525
	5   MEGA                                0x000000010b413732 ___ZN24DelegateMEGAChatListener20onChatListItemUpdateEPN8megachat11MegaChatApiEPNS0_16MegaChatListItemE_block_invoke + 130
	6   libdispatch.dylib                   0x00000001138ec3f7 _dispatch_call_block_and_release + 12
	7   libdispatch.dylib                   0x00000001138ed43c _dispatch_client_callout + 8
	8   libdispatch.dylib                   0x00000001138f86f0 _dispatch_main_queue_callback_4CF + 628
	9   CoreFoundation                      0x000000010e76bef9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	10  CoreFoundation                      0x000000010e730662 __CFRunLoopRun + 2402
	11  CoreFoundation                      0x000000010e72fa89 CFRunLoopRunSpecific + 409
	12  GraphicsServices                    0x00000001163fd9c6 GSEventRunModal + 62
	13  UIKit                               0x0000000111635d30 UIApplicationMain + 159
	14  MEGA                                0x000000010b31dfe7 main + 151
	15  libdyld.dylib                       0x0000000113969d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
commented

Changing this in ChatRoomsViewController.m around line 710 resolves this.

                case MEGAChatListItemChangeTypeLastTs:
                   if (!self.chatListItemArray || !self.chatListItemArray.count ) {
                       [self.chatListItemArray addObject:(item)];
                    }
                   else{
                       [self.chatListItemArray replaceObjectAtIndex:indexPath.row withObject:item];
                   }
                    [self updateCell:cell forChatListItem:item];
                    break;