There is no real issue in that code at this moment but it's only a lucky
coincidence. If there was another element in group_attrs before member, the
result would be SIGABRT.
Not really a memleak because of the memory hierarchy but I think it's nice to
clean up memory when rewriting a pointer.
I found this while closely going through the file to implement ghost users.
After discovering this, I re-checked it twice to be sure. To enter the block
of code, it would require RFC2307 and populate_members set to false.
But when you go through the file, the only place where sdap_save_groups() is
called for RFC2307 is in sdap_get_groups_done() and it is called with
populate_users = true.
Because of the change in previous patch, there is only one place where this
function is called and it is bound with RFC230bis.
The attached patch restores umask right after the temp file is created
to avoid needing a restore code and moves freeing allocated resources
into the done: label so they are reclaimed even in case some function
fails end we end up jumping to "done".