Context: I'm working on CBSD [1] and trying to learn how the shell works, so I'm starting to read the source from CBSD and FreeBSD. I'm moving into Terra incognita, so feel free to let me know if I've missed anything for this patch.
Reading the source of sbin/cddconfig/cddconfig.c I saw an error on realloc's use aka CWE: 401 - Common realloc mistake: 'xx' nulled but not freed upon failure
The fix is simple. It has already been applied on OpenBSD [2] and NetBSD [3]
I kept the name for the variable: nargv.
[1] https://cbsd.io/ - https://github.com/cbsd/cbsd
[2] https://github.com/openbsd/src/blob/9ce3fac739d1116b52eeba34a7f2aa2a96249e70/sbin/ccdconfig/ccdconfig.c#L351
[3] https://github.com/NetBSD/src/blob/trunk/sbin/ccdconfig/ccdconfig.c#L329