Hi, I seem to find some possible memory leaks in Samba code. The patch is attached, Could you guys have a look to check whether it is correct?
Thanks a lot. Leo --- samba-2.2.7a/source/lib/util.c.old Fri Jan 24 12:06:46 2003 +++ samba-2.2.7a/source/lib/util.c Fri Jan 24 12:07:50 2003 @@ -1284,10 +1284,13 @@ routine to free a namearray. void free_namearray(name_compare_entry *name_array) { + int i; if(name_array == NULL) return; - SAFE_FREE(name_array->name); + for(i=0; name_array[i].name!=NULL; i++) + SAFE_FREE(name_array[i].name); + SAFE_FREE(name_array); } --- samba-2.2.7a/source/smbd/posix_acls.c.old Fri Jan 24 12:06:31 2003 +++ samba-2.2.7a/source/smbd/posix_acls.c Fri Jan 24 12:11:49 2003 @@ -912,9 +912,10 @@ Deny entry after Allow entry. Failing to free_canon_ace_list(dir_ace); return False; } - + SAFE_FREE(current_ace); current_ace = dup_ace; } else { + SAFE_FREE(current_ace); current_ace = NULL; } } @@ -949,6 +950,7 @@ Deny entry after Allow entry. Failing to print_canon_ace( current_ace, 0); } all_aces_are_inherit_only = False; + SAFE_FREE(current_ace); current_ace = NULL; } @@ -1096,6 +1098,7 @@ static void process_deny_list( canon_ace /* Deny nothing entry - delete. */ DLIST_REMOVE(ace_list, curr_ace); + SAFE_FREE(curr_ace); continue; } @@ -1141,6 +1144,7 @@ static void process_deny_list( canon_ace */ DLIST_REMOVE(ace_list, curr_ace); + SAFE_FREE(curr_ace); } /* Pass 2 above - deal with deny user entries. */ @@ -2306,6 +2310,7 @@ BOOL set_nt_acl(files_struct *fsp, uint3 if (conn->vfs_ops.sys_acl_delete_def_file(conn, dos_to_unix_static(fsp->fsp_name)) == -1) { DEBUG(3,("set_nt_acl: conn->vfs_ops.sys_acl_delete_def_file failed (%s)\n", strerror(errno))); free_canon_ace_list(file_ace_list); + free_canon_ace_list(dir_ace_list); return False; } } __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com