Skip to content

Commit 640516b

Browse files
authored
fix buffer overflow
1 parent 5fcec8b commit 640516b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: threading/smartptrs.nim

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ proc newSharedPtr*[T](t: typedesc[T]): SharedPtr[T] =
108108
## Returns a shared pointer. It is not initialized,
109109
## so reading from it before writing to it is undefined behaviour!
110110
when not supportsCopyMem(T):
111-
result.val = cast[typeof(result.val)](allocShared0(sizeof(T)))
111+
result.val = cast[typeof(result.val)](allocShared0(sizeof(result.val[])))
112112
else:
113-
result.val = cast[typeof(result.val)](allocShared(sizeof(T)))
113+
result.val = cast[typeof(result.val)](allocShared(sizeof(result.val[])))
114114
int(result.val.counter) = 0
115115

116116
proc isNil*[T](p: SharedPtr[T]): bool {.inline.} =

0 commit comments

Comments
 (0)