From dee976e6b7c0d3fe963e74e5b0e9891e8ee22224 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Fri, 1 May 2026 07:17:42 +0100 Subject: [PATCH] Fix: `Model::try_set_option`: Return error if option name contains NUL char Currently it panics in the case that there is a NUL char in the option name, but there's no reason really to treat these bad option names as different from any other. Return an error in this case too. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 67d3d67..10a176e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -733,7 +733,7 @@ impl HighsPtr { option: STR, value: V, ) -> Result<(), TrySetOptionError> { - let c_str = CString::new(option).expect("Option name contains NUL char"); + let c_str = CString::new(option).map_err(|_| TrySetOptionError {})?; let status = unsafe { value.apply_to_highs(self.mut_ptr(), c_str.as_ptr()) }; match try_handle_status(status, "Highs_setOptionValue") { Ok(_) => Ok(()),