afc.c: fixed leaks in various functions when an invalid argument error is returned.