Skip to content

Commit 2c71ed7

Browse files
committed
[Rust] Fix load options string not being terminated
1 parent b2da8f6 commit 2c71ed7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

rust/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ where
194194
{
195195
let file_path = file_path.as_ref().to_cstr();
196196
let options_or_default = if let Some(opt) = options {
197-
opt.get_json_string().ok()?.to_cstr().to_bytes().to_vec()
197+
opt.get_json_string()
198+
.ok()?
199+
.to_cstr()
200+
.to_bytes_with_nul()
201+
.to_vec()
198202
} else {
199203
Metadata::new_of_type(MetadataType::KeyValueDataType)
200204
.get_json_string()
@@ -242,7 +246,11 @@ where
242246
P: ProgressCallback,
243247
{
244248
let options_or_default = if let Some(opt) = options {
245-
opt.get_json_string().ok()?.to_cstr().to_bytes().to_vec()
249+
opt.get_json_string()
250+
.ok()?
251+
.to_cstr()
252+
.to_bytes_with_nul()
253+
.to_vec()
246254
} else {
247255
Metadata::new_of_type(MetadataType::KeyValueDataType)
248256
.get_json_string()

0 commit comments

Comments
 (0)