fix: validate LTHashState version to prevent app state crashes
fix: validate LTHashState version to prevent app state crashes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user