Skip to content

Commit b32fb44

Browse files
committed
fix: hardsubx segmentation fault
1 parent 92ba6ae commit b32fb44

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/rust/src/hardsubx/decoder.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ pub unsafe fn dispatch_classifier_functions(ctx: *mut lib_hardsubx_ctx, im: *mut
4141
match (*ctx).ocr_mode {
4242
0 => {
4343
let ret_char_arr = get_ocr_text_wordwise_threshold(ctx, im, (*ctx).conf_thresh);
44-
ffi::CStr::from_ptr(ret_char_arr)
45-
.to_string_lossy()
46-
.into_owned()
44+
if ret_char_arr.is_null() {
45+
"".to_string()
46+
} else {
47+
ffi::CStr::from_ptr(ret_char_arr)
48+
.to_string_lossy()
49+
.into_owned()
50+
}
4751
}
4852
1 => {
4953
let ret_char_arr = get_ocr_text_letterwise_threshold(ctx, im, (*ctx).conf_thresh);

0 commit comments

Comments
 (0)