Skip to content

Commit

Permalink
fix 'use after free'
Browse files Browse the repository at this point in the history
  • Loading branch information
pygy committed Jan 30, 2024
1 parent 5c2066d commit 4b17500
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,28 @@ type Life = (life: {
function Ref(cb: Life) {
const nr = fromParent(Range)
zoneRemoveMap.set(nr, Zone)
asapQueue = []
withRange(nr, () => {
canCallHooks = 4
let res
try{
res = cb({asap, rendered, reflowed, removing})
} finally {
let previous = asapQueue
try {
asapQueue = []
withRange(nr, () => {
canCallHooks = 4
let res
try{
res = cb({asap, rendered, reflowed, removing})
} finally {
canCallHooks = 0
}
emit(res)
})
S.freeze(() => {
canCallHooks = 3
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
asapQueue!.forEach(cb => forEachNode(nr as NonNullNodeRange, cb))
canCallHooks = 0
}
emit(res)
})
S.freeze(() => {
canCallHooks = 3
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
asapQueue!.forEach(cb => forEachNode(nr as NonNullNodeRange, cb))
canCallHooks = 0
})
asapQueue = null
})
} finally {
asapQueue = previous
}
}


Expand Down

0 comments on commit 4b17500

Please sign in to comment.