about summary refs log tree commit diff stats
path: root/src/js
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-05 17:11:04 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-05 17:11:04 +0200
commit4981c6f2d365363a78a4eb3cdea3776a19dd41cb (patch)
treec4a8f96a553a2101f62921e957c31bbfb3c1545d /src/js
parentc5d774073a90d122c757b677c149e11c7564e8e0 (diff)
downloadchawan-4981c6f2d365363a78a4eb3cdea3776a19dd41cb.tar.gz
Fix empty string crash/regression
Oops
Diffstat (limited to 'src/js')
-rw-r--r--src/js/javascript.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim
index 5bffbdbd..0d86bd71 100644
--- a/src/js/javascript.nim
+++ b/src/js/javascript.nim
@@ -227,7 +227,7 @@ proc setInterruptHandler*(rt: JSRuntime, cb: JSInterruptHandler, opaque: pointer
 func toString*(ctx: JSContext, val: JSValue): Option[string] =
   var plen: csize_t
   let outp = JS_ToCStringLen(ctx, addr plen, val) # cstring
-  if outp != nil:
+  if outp != nil and plen != 0:
     var ret = newString(plen)
     copyMem(addr ret[0], outp, plen)
     result = some(ret)