diff --git a/src/header/getopt/mod.rs b/src/header/getopt/mod.rs index 56ab087ea7..5a3d926fb9 100644 --- a/src/header/getopt/mod.rs +++ b/src/header/getopt/mod.rs @@ -86,7 +86,9 @@ pub unsafe extern "C" fn getopt_long( if unsafe { string::strncmp(current_arg, opt.name, end as size_t) == 0 } { unsafe { optind += 1; - *longindex = i as c_int; + if !longindex.is_null() { + *longindex = i as c_int; + } } if opt.has_arg == optional_argument {