Skip to content

Commit

Permalink
Copy all Strings received from agentcore instead of using raw pointer (
Browse files Browse the repository at this point in the history
…#126)

* Add debug to diagnose test crash on Travis

* Try copying bad string

* remove debug
  • Loading branch information
sjanuary authored and mattcolegate committed May 22, 2017
1 parent 0e28d0a commit 463c523
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/SwiftMetrics/SwiftMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ private func receiveAgentCoreData(cSourceId: UnsafePointer<CChar>, cSize: CUnsig
}
let source = String(cString: cSourceId)
if source != "api" {
let message = String(bytesNoCopy: data, length: size, encoding: String.Encoding.utf8, freeWhenDone: false) ?? ""
let opaquePointer = OpaquePointer(data)
let cstrPointer = UnsafePointer<CChar>(opaquePointer)

let message = String(cString:cstrPointer) ?? ""
if swiftMon != nil {
swiftMon!.raiseCoreEvent(topic: source, message: message)
}
Expand Down

0 comments on commit 463c523

Please sign in to comment.