We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
CString
execute_without_results
1 parent a6a4b46 commit 30efdf1Copy full SHA for 30efdf1
src/connection/mod.rs
@@ -393,10 +393,13 @@ impl Connection {
393
394
/// Fully Executes provided query but doesn't return any results even if they exist.
395
pub fn execute_without_results(&mut self, query: &str) -> Result<(), MgError> {
396
+ // Allocate the C string without leaking. Keep it alive for the duration of the FFI call.
397
+ let c_query = CString::new(query).map_err(|_| MgError::new("Invalid query".to_string()))?;
398
+
399
match unsafe {
400
bindings::mg_session_run(
401
self.mg_session,
- str_to_c_str(query),
402
+ c_query.as_ptr(), // no leak: pointer valid during this call
403
std::ptr::null(),
404
std::ptr::null_mut(),
405
0 commit comments