Skip to content

Commit

Permalink
Merge pull request #1565 from canalplus/fix/maxSessionCacheSize-off-b…
Browse files Browse the repository at this point in the history
…y-one

Fix off by 1 issue in when relying on `keySystems[].maxSessionCacheSize`
  • Loading branch information
peaBerberian authored Oct 15, 2024
2 parents 3f297e5 + 04d66cc commit 38e1d93
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main_thread/decrypt/create_or_load_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ export default async function createOrLoadSession(
}
}

await cleanOldLoadedSessions(loadedSessionsStore, maxSessionCacheSize);
await cleanOldLoadedSessions(
loadedSessionsStore,
// Account for the next session we will be creating
// Note that `maxSessionCacheSize < 0 has special semantic (no limit)`
maxSessionCacheSize <= 0 ? maxSessionCacheSize : maxSessionCacheSize - 1,
);
if (cancelSignal.cancellationError !== null) {
throw cancelSignal.cancellationError; // stop here if cancelled since
}
Expand Down

0 comments on commit 38e1d93

Please sign in to comment.