* src/chmod.c: Deallocate the mode change array in dev mode.
* src/chown.c: Make chopt_free() actually deallocate, but
only call in dev mode.
* src/chgrp.c: Likewise.
else
{
char *group_name = argv[optind++];
- chopt.group_name = (*group_name ? group_name : NULL);
+ chopt.group_name = (*group_name ? xstrdup (group_name) : NULL);
gid = parse_group (group_name);
}
(uid_t) -1, gid,
(uid_t) -1, (gid_t) -1, &chopt);
- chopt_free (&chopt);
+ IF_LINT (chopt_free (&chopt));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
ok = process_files (argv + optind,
FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
+ IF_LINT (free (change));
+
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
chopt->group_name = NULL;
}
+extern void
+chopt_free (struct Chown_option *chopt)
+{
+ free (chopt->user_name);
+ free (chopt->group_name);
+}
+
/* Convert the numeric group-id, GID, to a string stored in xmalloc'd memory,
and return it. If there's no corresponding group name, use the decimal
representation of the ID. */
void
chopt_init (struct Chown_option *);
-/* Deliberately do not free chopt->user_name or ->group_name.
- They're not always allocated. */
-# define chopt_free(chopt)
+void
+chopt_free (struct Chown_option *);
char *
gid_to_name (gid_t) _GL_ATTRIBUTE_MALLOC;
empty string so that diagnostics say "ownership :GROUP"
rather than "group GROUP". */
if (!chopt.user_name && chopt.group_name)
- chopt.user_name = bad_cast ("");
+ chopt.user_name = xstrdup ("");
optind++;
}
uid, gid,
required_uid, required_gid, &chopt);
- chopt_free (&chopt);
+ IF_LINT (chopt_free (&chopt));
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}