diff --git a/Cargo.lock b/Cargo.lock index 14963fd9b4..c79063463e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1316,6 +1316,7 @@ dependencies = [ "rmp-serde", "serde", "serde_json", + "tinybytes", "tokio", "tokio-util", "uuid", @@ -1984,7 +1985,6 @@ dependencies = [ "datadog-trace-protobuf", "ddcommon 0.0.1", "http 0.2.11", - "hyper 0.14.28", "serde", "tracing", ] diff --git a/profiling/src/timeline.rs b/profiling/src/timeline.rs index 970de53551..efbbd9a1f4 100644 --- a/profiling/src/timeline.rs +++ b/profiling/src/timeline.rs @@ -204,21 +204,16 @@ unsafe extern "C" fn ddog_php_prof_zend_error_observer( } #[cfg(zend_error_observer_80)] - let file = unsafe { - let mut len = 0; - let file = file as *const u8; - while *file.add(len) != 0 { - len += 1; - } - std::str::from_utf8_unchecked(std::slice::from_raw_parts(file, len)).to_string() - }; + let filename_str = unsafe { core::ffi::CStr::from_ptr(file) }; #[cfg(not(zend_error_observer_80))] - let file = unsafe { zend::zai_str_from_zstr(file.as_mut()).into_string() }; + let filename_str = unsafe { zai_str_from_zstr(file.as_mut()) }; + + let filename = filename_str.to_string_lossy().into_owned(); let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); if let Some(profiler) = Profiler::get() { let now = now.as_nanos() as i64; - profiler.collect_fatal(now, file, line, unsafe { + profiler.collect_fatal(now, filename, line, unsafe { zend::zai_str_from_zstr(message.as_mut()).into_string() }); }