瀏覽代碼

do not try to create a Data object by UnsafeBufferPointer that point to already unref'd data

B. Petersen 3 年之前
父節點
當前提交
45d67a4b73
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      DcCore/DcCore/DC/Wrapper.swift

+ 2 - 1
DcCore/DcCore/DC/Wrapper.swift

@@ -1113,8 +1113,9 @@ public class DcMsg {
 
 
         let count = ptrSize.pointee
         let count = ptrSize.pointee
         let buffer = UnsafeBufferPointer<Int8>(start: ccharPtr, count: count)
         let buffer = UnsafeBufferPointer<Int8>(start: ccharPtr, count: count)
+        let data = Data(buffer: buffer)
         dc_str_unref(ccharPtr)
         dc_str_unref(ccharPtr)
-        return Data(buffer: buffer)
+        return data
     }
     }
 
 
     public func getWebxdcInfoJson() -> String {
     public func getWebxdcInfoJson() -> String {