@@ -1439,26 +1439,25 @@ int do_command6(int argc, char *argv[], char **table, void **handle)
14391439 opterr = 0 ;
14401440
14411441 /* Create a malloc'd copy of orig_opts */
1442+ size_t num_opts = 0 ;
1443+ struct option * orig_opts = iptables_globals .orig_opts ;
1444+
1445+ /* Count the number of options (including the NULL terminator) */
1446+ while (orig_opts [num_opts ].name != NULL ) {
1447+ num_opts ++ ;
1448+ }
1449+ num_opts ++ ; /* Include the NULL terminator */
1450+
1451+ /* Allocate memory and copy the options */
1452+ iptables_globals .opts = malloc (num_opts * sizeof (struct option ));
14421453 if (iptables_globals .opts == NULL ) {
1443- size_t num_opts = 0 ;
1444- struct option * orig_opts = iptables_globals .orig_opts ;
1445-
1446- /* Count the number of options (including the NULL terminator) */
1447- while (orig_opts [num_opts ].name != NULL ) {
1448- num_opts ++ ;
1449- }
1450- num_opts ++ ; /* Include the NULL terminator */
1451-
1452- /* Allocate memory and copy the options */
1453- iptables_globals .opts = malloc (num_opts * sizeof (struct option ));
1454- if (iptables_globals .opts == NULL ) {
1455- xtables_error (OTHER_PROBLEM , "malloc failed for options array" );
1456- }
1457- memcpy (iptables_globals .opts , iptables_globals .orig_opts , num_opts * sizeof (struct option ));
1454+ xtables_error (OTHER_PROBLEM , "malloc failed for options array" );
14581455 }
1456+ memcpy (iptables_globals .opts , iptables_globals .orig_opts , num_opts * sizeof (struct option ));
1457+
14591458 while ((cs .c = getopt_long (argc , argv ,
14601459 "-:A:C:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:bvnt:m:xc:g:46" ,
1461- iptables_globals .opts ?: iptables_globals . orig_opts , NULL )) != -1 ) {
1460+ iptables_globals .opts , NULL )) != -1 ) {
14621461 switch (cs .c ) {
14631462 /*
14641463 * Command selection
0 commit comments