Skip to content

Commit 0cc42f5

Browse files
committed
fix: NULLポインタチェックを追加してセグメンテーション違反を防止
1 parent 37a8dd1 commit 0cc42f5

File tree

1 file changed

+8
-0
lines changed
  • crates/shiguredo_nvcodec/src

1 file changed

+8
-0
lines changed

crates/shiguredo_nvcodec/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ impl CudaLibrary {
233233
// NOTE: 無限再帰を避けるために、ここでは Error::check_cuda() は使わない
234234
return None;
235235
}
236+
if error_name.is_null() {
237+
// ここには来ないはずだけど保守的に NULL チェックを入れておく
238+
return None;
239+
}
236240

237241
let error_str = std::ffi::CStr::from_ptr(error_name as *const i8)
238242
.to_string_lossy()
@@ -253,6 +257,10 @@ impl CudaLibrary {
253257
// NOTE: 無限再帰を避けるために、ここでは Error::check_cuda() は使わない
254258
return None;
255259
}
260+
if error_msg.is_null() {
261+
// ここには来ないはずだけど保守的に NULL チェックを入れておく
262+
return None;
263+
}
256264

257265
let error_str = std::ffi::CStr::from_ptr(error_msg as *const i8)
258266
.to_string_lossy()

0 commit comments

Comments
 (0)