diff options
author | bptato <nincsnevem662@gmail.com> | 2024-06-22 18:02:31 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-06-22 18:03:26 +0200 |
commit | 3e353c07a5c3d5f6c22062adf684cea59c0e86a3 (patch) | |
tree | 4051744ea375ee697cb3615bc5f6fe7cb4766e3f /src | |
parent | 9ddcec100e09ac85c1a0746fe05df855bed720ea (diff) | |
download | chawan-3e353c07a5c3d5f6c22062adf684cea59c0e86a3.tar.gz |
pager: fix nil deref in dupeBuffer
Diffstat (limited to 'src')
-rw-r--r-- | src/local/pager.nim | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/local/pager.nim b/src/local/pager.nim index 411ef1b1..5a3f84eb 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -8,6 +8,7 @@ import std/selectors import std/tables import std/unicode +import chagashi/charset import config/chapath import config/config import config/mailcap @@ -50,8 +51,6 @@ import utils/regexutils import utils/strwidth import utils/twtstr -import chagashi/charset - type LineMode* = enum lmLocation = "URL: " @@ -688,19 +687,23 @@ func findProcMapItem*(pager: Pager; pid: int): int = -1 proc dupeBuffer(pager: Pager; container: Container; url: URL) = - container.clone(url, pager.loader).then(proc(container: Container) = - if container == nil: - pager.alert("Failed to duplicate buffer.") - else: - pager.addContainer(container) - pager.procmap.add(ProcMapItem( - container: container, - fdin: -1, - fdout: -1, - istreamOutputId: -1, - ostreamOutputId: -1 - )) - ) + let p = container.clone(url, pager.loader) + if p == nil: + pager.alert("Failed to duplicate buffer.") + else: + p.then(proc(container: Container) = + if container == nil: + pager.alert("Failed to duplicate buffer.") + else: + pager.addContainer(container) + pager.procmap.add(ProcMapItem( + container: container, + fdin: -1, + fdout: -1, + istreamOutputId: -1, + ostreamOutputId: -1 + )) + ) proc dupeBuffer(pager: Pager) {.jsfunc.} = pager.dupeBuffer(pager.container, pager.container.url) |