diff options
author | bptato <nincsnevem662@gmail.com> | 2024-07-19 19:29:10 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-07-19 19:29:10 +0200 |
commit | 38cc49aa7f8a9d616cb57ce025a2add3e855f5c9 (patch) | |
tree | 8e178276860e9462a4ba5b1a5b3e29b7f9ca2279 /src | |
parent | b896a683b31892bb732909966875d35e1906b778 (diff) | |
download | chawan-38cc49aa7f8a9d616cb57ce025a2add3e855f5c9.tar.gz |
buffer: fix nil deref on click without clickable element
Diffstat (limited to 'src')
-rw-r--r-- | src/html/dom.nim | 3 | ||||
-rw-r--r-- | src/server/buffer.nim | 9 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 9b092e3d..123296f5 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -2479,8 +2479,6 @@ proc dispatchEvent*(window: Window; event: Event; target: EventTarget): #TODO this is far from being compliant var called = false var canceled = false - let ctx = window.jsctx - var jsEvent = ctx.toJS(event) var stop = false window.dispatchEvent0(event, target, called, stop, canceled) if not stop and target of Node: @@ -2488,7 +2486,6 @@ proc dispatchEvent*(window: Window; event: Event; target: EventTarget): window.dispatchEvent0(event, a, called, stop, canceled) if stop: break - JS_FreeValue(ctx, jsEvent) return (called, canceled) proc fireEvent*(window: Window; name: StaticAtom; target: EventTarget) = diff --git a/src/server/buffer.nim b/src/server/buffer.nim index 424c210f..fa63f3a9 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -1567,10 +1567,11 @@ proc click*(buffer: Buffer; cursorx, cursory: int): ClickResult {.proxy.} = let clickable = buffer.getCursorClickable(cursorx, cursory) if buffer.config.scripting: let element = buffer.getCursorElement(cursorx, cursory) - let event = newEvent(buffer.window.toAtom(satClick), element) - (called, canceled) = buffer.window.dispatchEvent(event, element) - if called: - buffer.do_reshape() + if element != nil: + let event = newEvent(buffer.window.toAtom(satClick), element) + (called, canceled) = buffer.window.dispatchEvent(event, element) + if called: + buffer.do_reshape() if not canceled: if clickable != nil: var res = buffer.click(clickable) |