summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorSaem Ghani <saemghani+github@gmail.com>2021-02-23 00:02:06 -0800
committerGitHub <noreply@github.com>2021-02-23 09:02:06 +0100
commit7c2ac988805111df999dd4f586471627ee80efbb (patch)
tree331b03c11a0d760270f17787cd8aa2a47f21b66a /compiler
parent4e619a6bea75829638a87d53b1d806aface322e7 (diff)
downloadNim-7c2ac988805111df999dd4f586471627ee80efbb.tar.gz
Fixes #17039 - ldObj checks node/nodeAddr access (#17123)
Checked field expressions, such as an object variant field access results in
occasionally broken address analysis crashing the VM. This guard added here
mimics guarded access in ldObjAddr as well. This is to prevent a crash, while a
fix is devised.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/vm.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 246d9d4d2..ba14f2d51 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -711,7 +711,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
     of opcLdObj:
       # a = b.c
       decodeBC(rkNode)
-      let src = regs[rb].node
+      let src = if regs[rb].kind == rkNode: regs[rb].node else: regs[rb].nodeAddr[]
       case src.kind
       of nkEmpty..nkNilLit:
         # for nkPtrLit, this could be supported in the future, use something like: