Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in toData #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Cereal/CerealSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ private extension CoderTreeValue {

extension CoderTreeValue {
func toData() -> Data {
let bytes = self.bytes()

return Data(bytes: UnsafePointer<UInt8>(bytes), count: bytes.count)
return Data(self.bytes())
}
func bytes() -> [UInt8] {
var result = [UInt8]()
Expand Down Expand Up @@ -389,7 +387,7 @@ private extension CoderTreeValue {

case .data:
let valueBytes = Array(bytes[startIndex..<endIndex])
let data = Data(bytes: UnsafePointer<UInt8>(valueBytes), count: valueBytes.count)
let data = Data(valueBytes)
self = .data(data)

default:
Expand Down