fix: validate LTHashState version to prevent app state crashes

fix: validate LTHashState version to prevent app state crashes
This commit is contained in:
Renato Alcara
2026-02-20 01:19:04 -03:00
committed by GitHub
parent cd8c7d5a16
commit cbe5205dfd
2 changed files with 10 additions and 1 deletions
+7
View File
@@ -131,6 +131,13 @@ const generatePatchMac = (
export const newLTHashState = (): LTHashState => ({ version: 0, hash: Buffer.alloc(128), indexValueMap: {} })
export const ensureLTHashStateVersion = (state: LTHashState): LTHashState => {
if (typeof state.version !== 'number' || isNaN(state.version)) {
state.version = 0
}
return state
}
export const encodeSyncdPatch = async (
{ type, index, syncAction, apiVersion, operation }: WAPatchCreate,
myAppStateKeyId: string,