Some memory leak fixes.
authorTim Potter <tpot@samba.org>
Fri, 11 Jan 2002 03:49:51 +0000 (03:49 +0000)
committerTim Potter <tpot@samba.org>
Fri, 11 Jan 2002 03:49:51 +0000 (03:49 +0000)
(This used to be commit da4db0373b65d975d5129715d6b1fa725b188766)

source3/nsswitch/wbinfo.c

index 08b444a7c84633d46332287e8a7b69247443faf1..ab5d98bf9e569e7581eb21cb0753c74190fa780a 100644 (file)
@@ -93,13 +93,13 @@ static BOOL wbinfo_get_usergroups(char *user)
 
        result = winbindd_request(WINBINDD_GETGROUPS, &request, &response);
 
-       if (result != NSS_STATUS_SUCCESS) {
+       if (result != NSS_STATUS_SUCCESS)
                return False;
-       }
 
-       for (i = 0; i < response.data.num_entries; i++) {
+       for (i = 0; i < response.data.num_entries; i++)
                printf("%d\n", (int)((gid_t *)response.extra_data)[i]);
-       }
+
+       SAFE_FREE(response.extra_data);
 
        return True;
 }
@@ -123,10 +123,12 @@ static BOOL wbinfo_list_domains(void)
        /* Display response */
 
        if (response.extra_data) {
-               while(next_token((char **)&response.extra_data, name, ",", 
-                                sizeof(fstring))) {
+               char *extra_data = (char *)response.extra_data;
+
+               while(next_token(&extra_data, name, ",", sizeof(fstring)))
                        printf("%s\n", name);
-               }
+
+               SAFE_FREE(response.extra_data);
        }
 
        return True;
@@ -413,6 +415,7 @@ static BOOL wbinfo_auth_crap(char *username)
 static BOOL print_domain_users(void)
 {
        struct winbindd_response response;
+       char *extra_data;
        fstring name;
 
        /* Send request to winbind daemon */
@@ -426,15 +429,16 @@ static BOOL print_domain_users(void)
 
        /* Look through extra data */
 
-       if (!response.extra_data) {
+       if (!response.extra_data)
                return False;
-       }
 
-       while(next_token((char **)&response.extra_data, name, ",", 
-                        sizeof(fstring))) {
+       extra_data = (char *)response.extra_data;
+
+       while(next_token(&extra_data, name, ",", sizeof(fstring)))
                printf("%s\n", name);
-       }
        
+       SAFE_FREE(response.extra_data);
+
        return True;
 }
 
@@ -443,6 +447,7 @@ static BOOL print_domain_users(void)
 static BOOL print_domain_groups(void)
 {
        struct winbindd_response response;
+       char *extra_data;
        fstring name;
 
        ZERO_STRUCT(response);
@@ -454,14 +459,15 @@ static BOOL print_domain_groups(void)
 
        /* Look through extra data */
 
-       if (!response.extra_data) {
+       if (!response.extra_data)
                return False;
-       }
 
-       while(next_token((char **)&response.extra_data, name, ",", 
-                        sizeof(fstring))) {
+       extra_data = (char *)response.extra_data;
+
+       while(next_token(&extra_data, name, ",", sizeof(fstring)))
                printf("%s\n", name);
-       }
+
+       SAFE_FREE(response.extra_data);
        
        return True;
 }