Likewise, update_groups() duplicates each regular group with __gr_dup()
and never frees the 'ngrp' copy. Release it with gr_free(); as with
__sgr_dup(), the duplicate owns deep-copied fields, so free() alone would
leak them.
valgrind --leak-check=full --show-leak-kinds=all src/userdel -P <prefix> bob,
before this commit:
471 (320 direct, 151 indirect) bytes in 10 blocks are definitely lost
at 0x4848EB8: calloc
by __gr_dup (groupmem.c:28)
by update_groups (userdel.c:197)
definitely lost: 800 bytes in 40 blocks
after this commit:
definitely lost: 480 bytes in 30 blocks
Signed-off-by: Artem Semenov <savoptik@altlinux.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
#endif /* WITH_AUDIT */
SYSLOG(LOG_INFO, "delete '%s' from group '%s'\n",
user_name, ngrp->gr_name);
+ gr_free (ngrp);
}
if (getdef_bool ("USERGROUPS_ENAB")) {