Skip to content

Commit

Permalink
refs nim-lang#16613: check opcWrDeref for nil (nim-lang#18613)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored and PMunch committed Mar 28, 2022
1 parent b6d9436 commit 32ce493
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions compiler/vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,10 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
# vmgen generates opcWrDeref, which means that we must dereference
# twice.
# TODO: This should likely be handled differently in vmgen.
if (nfIsRef notin regs[ra].nodeAddr[].flags and
nfIsRef notin n.flags):
regs[ra].nodeAddr[][] = n[]
else:
regs[ra].nodeAddr[] = n
let nAddr = regs[ra].nodeAddr
if nAddr[] == nil: stackTrace(c, tos, pc, "opcWrDeref internal error") # refs bug #16613
if (nfIsRef notin nAddr[].flags and nfIsRef notin n.flags): nAddr[][] = n[]
else: nAddr[] = n
of rkRegisterAddr: regs[ra].regAddr[] = regs[rc]
of rkNode:
# xxx: also check for nkRefTy as in opcLdDeref?
Expand Down

0 comments on commit 32ce493

Please sign in to comment.