From ad245e4229c0bb74c06e544ea9bc51c411afc717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Wed, 31 Jul 2024 10:49:48 +0200 Subject: [PATCH] Fix crash when 422 on join is returned MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/NCAPIController.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NextcloudTalk/NCAPIController.m b/NextcloudTalk/NCAPIController.m index 73db010fe..8ba1ec113 100644 --- a/NextcloudTalk/NCAPIController.m +++ b/NextcloudTalk/NCAPIController.m @@ -436,7 +436,12 @@ - (NSURLSessionDataTask *)joinRoom:(NSString *)token forAccount:(TalkAccount *)a [self checkResponseStatusCode:statusCode forAccount:account]; NSDictionary *errorDict = [[[self getFailureResponseObjectFromError:error] objectForKey:@"ocs"] objectForKey:@"data"]; - NSString *statusReason = [errorDict objectForKey:@"error"]; + NSString *statusReason = nil; + + // Depending on the error, an empty array instead of a dictionary is returned by the server + if (errorDict && [errorDict isKindOfClass:[NSDictionary class]]) { + statusReason = [errorDict objectForKey:@"error"]; + } if (block) { block(nil, nil, error, statusCode, statusReason);