From 89d7ed0120b73ecc44c5875c3b423ebf118c3132 Mon Sep 17 00:00:00 2001 From: Bendeguz Pisch Date: Tue, 16 Dec 2025 18:15:56 +0100 Subject: [PATCH] Allow NULL as longindex parameter on getopt_long --- src/header/getopt/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 {