Only free sgent if it was initialized

`sgent` is only initialized in `get_group()` if `is_shadowgrp` is true.
So we should also only attempt to free it if this is actually the case.

Can otherwise lead to:
```
free() double free detected in tcache 2 (gpasswd)
```
This commit is contained in:
Michael Vetter 2021-09-20 11:04:50 +02:00
parent 26bbee8c86
commit 117bc66c6f

View File

@ -1207,11 +1207,13 @@ int main (int argc, char **argv)
sssd_flush_cache (SSSD_DB_GROUP); sssd_flush_cache (SSSD_DB_GROUP);
#ifdef SHADOWGRP #ifdef SHADOWGRP
if (sgent.sg_adm) { if (is_shadowgrp) {
xfree(sgent.sg_adm); if (sgent.sg_adm) {
} xfree(sgent.sg_adm);
if (sgent.sg_mem) { }
xfree(sgent.sg_mem); if (sgent.sg_mem) {
xfree(sgent.sg_mem);
}
} }
#endif #endif
if (grent.gr_mem) { if (grent.gr_mem) {