diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-20 23:34:05 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-20 23:35:24 +0100 |
commit | 5e4e35899029c91597ac78eb27be488fdcd7f69b (patch) | |
tree | 5c955e6c5730aa86068a8eb63c3ebbd1395f963b /src/js | |
parent | 2b60e1009f54ef8d09bf66b092a613840e9ec59b (diff) | |
download | chawan-5e4e35899029c91597ac78eb27be488fdcd7f69b.tar.gz |
js: fix nil deref in jsgetprop
Turns out desc can in fact be nil.
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/javascript.nim | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim index 8f7f445c..78999668 100644 --- a/src/js/javascript.nim +++ b/src/js/javascript.nim @@ -946,10 +946,15 @@ macro jsgetprop*(fun: typed) = block `dl`: let retv = ctx.toJS(`jfcl`) if retv != JS_NULL: - desc[].setter = JS_UNDEFINED - desc[].getter = JS_UNDEFINED - desc[].value = retv - desc[].flags = 0 + if desc != nil: + # From quickjs.h: + # > If 1 is returned, the property descriptor 'desc' is filled + # > if != NULL. + # So desc may be nil. + desc[].setter = JS_UNDEFINED + desc[].getter = JS_UNDEFINED + desc[].value = retv + desc[].flags = 0 return cint(1) return cint(0) let jsProc = gen.newJSProc(getJSGetPropParams(), false) |