about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-06-22 23:30:26 +0200
committerbptato <nincsnevem662@gmail.com>2024-06-22 23:30:26 +0200
commitc0fc92b7e4e328259404c46d2bc604b38d6087b4 (patch)
tree1f31b8b75cf1199c3062616a2a64ff7156f2a481
parentf6db5536c834185f7078e9614db7cca9faf3d153 (diff)
downloadchawan-c0fc92b7e4e328259404c46d2bc604b38d6087b4.tar.gz
env: fix nil deref in client
-rw-r--r--src/html/env.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/html/env.nim b/src/html/env.nim
index e8fbf4af..0a90007f 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -138,7 +138,9 @@ proc devicePixelRatio(window: Window): float64 {.jsfget.} = 1
 
 proc setLocation(window: Window; s: string): Err[JSError]
     {.jsfset: "location".} =
-  window.document.setLocation(s)
+  if window.document == nil:
+    return errTypeError("document is null")
+  return window.document.setLocation(s)
 
 func getWindow(window: Window): Window {.jsuffget: "window".} =
   return window
href='#n114'>114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176