]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Fix xattr memory leak. Fixes bug 8475.
authorWayne Davison <wayned@samba.org>
Thu, 22 Sep 2011 16:02:21 +0000 (09:02 -0700)
committerWayne Davison <wayned@samba.org>
Thu, 22 Sep 2011 16:13:31 +0000 (09:13 -0700)
xattrs.c

index 3a7cb25bb87a299448e660cfbc2dedf3fd6ae45c..52c33cda6bd8063cb37da9658c011eba9ac402e3 100644 (file)
--- a/xattrs.c
+++ b/xattrs.c
@@ -94,11 +94,14 @@ static void rsync_xal_free(item_list *xalp)
        size_t i;
        rsync_xa *rxas = xalp->items;
 
+       if (!xalp->malloced)
+               return;
+
        for (i = 0; i < xalp->count; i++) {
                free(rxas[i].datum);
                /*free(rxas[i].name);*/
        }
-       xalp->count = 0;
+       free(xalp->items);
 }
 
 void free_xattr(stat_x *sxp)
@@ -773,10 +776,8 @@ void uncache_tmp_xattrs(void)
                item_list *xattr_start = xattr_item + prior_xattr_count;
                xattr_item += rsync_xal_l.count;
                rsync_xal_l.count = prior_xattr_count;
-               while (xattr_item-- > xattr_start) {
+               while (xattr_item-- > xattr_start)
                        rsync_xal_free(xattr_item);
-                       free(xattr_item->items);
-               }
                prior_xattr_count = (size_t)-1;
        }
 }