summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-06-11 11:55:08 +0800
committerGitHub <noreply@github.com>2024-06-11 05:55:08 +0200
commit262ff648aad7cc2062eb94cb6bf3357f9910c448 (patch)
tree30c2ea1624d342443e33d9b5d37c46aaca4f238b /lib/pure
parent8cbbe12ee4eaa9568d246638b1f712a5a57e20ab (diff)
downloadNim-262ff648aad7cc2062eb94cb6bf3357f9910c448.tar.gz
[backport] fixes #23690; SIGSEGV with object variants and RTTI (#23703)
fixes #23690

```nim
dest.`:state` = src.`:state`
var :tmp_553651276 = dest.e1.a
`=wasMoved`(dest.e1.a)
dest.e1.a.kind = src.e1.a.kind
case dest.e1.a.kind
of 0:
  dest.e1.a.a = src.e1.a.a
of 1:
  `=copy`(dest.e1.a.c, src.e1.a.c)
case :tmp_553651276.kind
of 0:
of 1:
  `=destroy`(:tmp_553651276.c)
```
`dest.e1.a.kind = src.e1.a.kind` changes the discrimant but it fails to
clear the memory of `dest.e1.a`. Before using hooks for copying, we need
to clear the dest, e.g. `=wasMoved(dest.e1.a.c)`.

```nim
dest.`:state` = src.`:state`
var :tmp_553651276 = dest.e1.a
`=wasMoved`(dest.e1.a)
dest.e1.a.kind = src.e1.a.kind
case dest.e1.a.kind
of 0:
  `=wasMoved`(dest.e1.a.a)
  dest.e1.a.a = src.e1.a.a
  `=wasMoved`(dest.e1.a.b)
of 1:
  `=wasMoved`(dest.e1.a.c)
  `=copy`(dest.e1.a.c, src.e1.a.c)
case :tmp_553651276.kind
of 0:
of 1:
  `=destroy`(:tmp_553651276.c)
```
Diffstat (limited to 'lib/pure')
0 files changed, 0 insertions, 0 deletions