Skip to content

Commit

Permalink
fix: null-terminate OpenVINO EP option strings, ref #250
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Aug 1, 2024
1 parent 1692d11 commit 227bc85
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/execution_providers/openvino.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::os::raw::c_void;
use std::{ffi::CString, os::raw::c_void};

use crate::{
error::{Error, Result},
Expand Down Expand Up @@ -123,18 +123,18 @@ impl ExecutionProvider for OpenVINOExecutionProvider {
fn register(&self, session_builder: &SessionBuilder) -> Result<()> {
#[cfg(any(feature = "load-dynamic", feature = "openvino"))]
{
let device_type = self.device_type.as_deref().map(CString::new).transpose()?;
let device_id = self.device_id.as_deref().map(CString::new).transpose()?;
let cache_dir = self.cache_dir.as_deref().map(CString::new).transpose()?;
let openvino_options = ort_sys::OrtOpenVINOProviderOptions {
device_type: self
.device_type
device_type: device_type
.as_ref()
.map_or_else(std::ptr::null, |x| x.as_bytes().as_ptr().cast::<std::ffi::c_char>()),
device_id: self
.device_id
device_id: device_id
.as_ref()
.map_or_else(std::ptr::null, |x| x.as_bytes().as_ptr().cast::<std::ffi::c_char>()),
num_of_threads: self.num_threads,
cache_dir: self
.cache_dir
cache_dir: cache_dir
.as_ref()
.map_or_else(std::ptr::null, |x| x.as_bytes().as_ptr().cast::<std::ffi::c_char>()),
context: self.context,
Expand Down

0 comments on commit 227bc85

Please sign in to comment.