File tree 2 files changed +4
-6
lines changed
2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -122,9 +122,9 @@ impl JemallocMemoryControl {
122
122
. unwrap ( )
123
123
. to_string ( ) ;
124
124
125
+ // `file_path_str` is leaked because `jemalloc_dump_mib.write` requires static lifetime
125
126
let file_path_str = Box :: leak ( file_path. into_boxed_str ( ) ) ;
126
- let file_path_bytes = unsafe { file_path_str. as_bytes_mut ( ) } ;
127
- let file_path_ptr = file_path_bytes. as_mut_ptr ( ) ;
127
+ let file_path_bytes = file_path_str. as_bytes ( ) ;
128
128
if let Err ( e) = self
129
129
. jemalloc_dump_mib
130
130
. write ( CStr :: from_bytes_with_nul ( file_path_bytes) . unwrap ( ) )
@@ -133,7 +133,6 @@ impl JemallocMemoryControl {
133
133
} else {
134
134
tracing:: info!( "Successfully dumped heap profile to {}" , file_name) ;
135
135
}
136
- let _ = unsafe { Box :: from_raw ( file_path_ptr) } ;
137
136
}
138
137
}
139
138
}
Original file line number Diff line number Diff line change @@ -154,9 +154,9 @@ impl MonitorService for MonitorServiceImpl {
154
154
. to_str ( )
155
155
. ok_or_else ( || Status :: internal ( "The file dir is not a UTF-8 String" ) ) ?;
156
156
157
+ // `file_path_str` is leaked because `prof::dump::write` requires static lifetime
157
158
let file_path_str = Box :: leak ( file_path. to_string ( ) . into_boxed_str ( ) ) ;
158
- let file_path_bytes = unsafe { file_path_str. as_bytes_mut ( ) } ;
159
- let file_path_ptr = file_path_bytes. as_mut_ptr ( ) ;
159
+ let file_path_bytes = file_path_str. as_bytes ( ) ;
160
160
let response = if let Err ( e) = tikv_jemalloc_ctl:: prof:: dump:: write (
161
161
CStr :: from_bytes_with_nul ( file_path_bytes) . unwrap ( ) ,
162
162
) {
@@ -165,7 +165,6 @@ impl MonitorService for MonitorServiceImpl {
165
165
} else {
166
166
Ok ( Response :: new ( HeapProfilingResponse { } ) )
167
167
} ;
168
- let _ = unsafe { Box :: from_raw ( file_path_ptr) } ;
169
168
response
170
169
}
171
170
You can’t perform that action at this time.
0 commit comments