Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(last-n-limits): crash on undefined

paweldomas4adaa6f1fdbc
diff --git a/react/features/base/lastn/functions.js b/react/features/base/lastn/functions.js
index 338fa3ae79..23cfede81b 100644
--- a/react/features/base/lastn/functions.js
+++ b/react/features/base/lastn/functions.js
@@ -40,6 +40,10 @@ export function validateLastNLimits(lastNLimits) {
* of participants or {@code undefined} otherwise.
*/
export function limitLastN(participantsCount, lastNLimits) {
+ if (!lastNLimits || !lastNLimits.keys) {
+ return undefined;
+ }
+
let selectedLimit;
for (const participantsN of lastNLimits.keys()) {
diff --git a/react/features/base/lastn/functions.test.js b/react/features/base/lastn/functions.test.js
index 3eb4d08d24..91b918b31b 100644
--- a/react/features/base/lastn/functions.test.js
+++ b/react/features/base/lastn/functions.test.js
@@ -1,6 +1,9 @@
import { limitLastN, validateLastNLimits } from './functions';
-describe('limitsLastN', () => {
+describe('limitLastN', () => {
+ it('handles undefined mapping', () => {
+ expect(limitLastN(0, undefined)).toBe(undefined);
+ });
describe('when a correct limit mapping is given', () => {
const limits = new Map();