X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fexport%2Fexport.c;h=3e4da699091110645362457b3d2f3e264949233e;hp=ba643b2c044f04c74a211cc91d68d8268ea8d71b;hb=5d954d871fb265af584faef5df6e2e7e6ada7c3b;hpb=e3b0046b4b12a6e05c0a7afd59ca5431ded51e96 diff --git a/support/export/export.c b/support/export/export.c index ba643b2..3e4da69 100644 --- a/support/export/export.c +++ b/support/export/export.c @@ -28,6 +28,18 @@ static int export_check(nfs_export *, struct hostent *, char *); static nfs_export * export_allowed_internal(struct hostent *hp, char *path); +static void +export_free(nfs_export *exp) +{ + xfree(exp->m_export.e_squids); + xfree(exp->m_export.e_sqgids); + free(exp->m_export.e_mountpoint); + free(exp->m_export.e_fslocdata); + + xfree(exp->m_export.e_hostname); + xfree(exp); +} + static void warn_duplicated_exports(nfs_export *exp, struct exportent *eep) { if (exp->m_export.e_flags != eep->e_flags) { @@ -117,6 +129,10 @@ export_dup(nfs_export *exp, struct hostent *hp) if (exp->m_export.e_hostname) new->m_export.e_hostname = xstrdup(exp->m_export.e_hostname); clp = client_dup(exp->m_client, hp); + if (clp == NULL) { + export_free(new); + return NULL; + } clp->m_count++; new->m_client = clp; new->m_mayexport = exp->m_mayexport; @@ -260,6 +276,10 @@ export_check(nfs_export *exp, struct hostent *hp, char *path) return client_check(exp->m_client, hp); } +/** + * export_freeall - deallocate all nfs_export records + * + */ void export_freeall(void) { @@ -270,16 +290,7 @@ export_freeall(void) for (exp = exportlist[i].p_head; exp; exp = nxt) { nxt = exp->m_next; client_release(exp->m_client); - if (exp->m_export.e_squids) - xfree(exp->m_export.e_squids); - if (exp->m_export.e_sqgids) - xfree(exp->m_export.e_sqgids); - if (exp->m_export.e_mountpoint) - free(exp->m_export.e_mountpoint); - if (exp->m_export.e_fslocdata) - xfree(exp->m_export.e_fslocdata); - xfree(exp->m_export.e_hostname); - xfree(exp); + export_free(exp); } for (j = 0; j < HASH_TABLE_SIZE; j++) { exportlist[i].entries[j].p_first = NULL;