diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m
index af1e30849d0ac2328a4ba1c3ec06dd8c7cf55233..058b3892c91af3bdbf5f7975e9bd88f8cc0d663b 100644
--- a/xcode/OLMKit/OLMAccount.m
+++ b/xcode/OLMKit/OLMAccount.m
@@ -133,6 +133,7 @@
         const char *error = olm_account_last_error(_account);
         NSLog(@"error getting id keys: %s", error);
         free(otkBytes);
+        return nil;
     }
     NSData *otk = [NSData dataWithBytesNoCopy:otkBytes length:otkLength freeWhenDone:YES];
     NSError *error = nil;