diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index 3b3a7d0..93f58c6 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -170,6 +170,12 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcod } } iface := (*interfaceHeader)(e.ptrToUnsafePtr(ptr)) + if iface == nil { + b = encodeNull(b) + b = encodeComma(b) + code = code.next + break + } ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(iface)) if iface.ptr == nil { b = encodeNull(b)