dentry_set_symlink_buf() fix
authorEric Biggers <ebiggers3@gmail.com>
Mon, 20 Aug 2012 17:31:46 +0000 (12:31 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 20 Aug 2012 17:31:46 +0000 (12:31 -0500)
src/mount.c
src/symlink.c

index 46da9e7..edd9cd1 100644 (file)
@@ -1426,6 +1426,8 @@ static int wimfs_symlink(const char *to, const char *from)
        if (dentry_set_symlink(dentry, to, w->lookup_table, &lte) != 0)
                goto out_free_dentry;
 
+       wimlib_assert(lte);
+
        dentry->ads_entries[1].lte_group_list.type = STREAM_TYPE_ADS;
        list_add(&dentry->ads_entries[1].lte_group_list.list,
                 &lte->lte_group_list);
index f7fa10d..3472ed1 100644 (file)
@@ -196,7 +196,9 @@ static int dentry_set_symlink_buf(struct dentry *dentry,
        if (!ads_entries)
                return WIMLIB_ERR_NOMEM;
        memcpy(ads_entries[1].hash, symlink_buf_hash, WIM_HASH_SIZE);
-       dentry_free_ads_entries(dentry);
+       wimlib_assert(dentry->num_ads == 0);
+       wimlib_assert(!dentry->ads_entries);
+       /*dentry_free_ads_entries(dentry);*/
        dentry->num_ads = 2;
        dentry->ads_entries = ads_entries;
        return 0;
@@ -226,6 +228,7 @@ int dentry_set_symlink(struct dentry *dentry, const char *target,
 
        if (existing_lte) {
                existing_lte->refcnt++;
+               lte = existing_lte;
        } else {
                DEBUG("Creating new lookup table entry for symlink buf");
                lte = new_lookup_table_entry();
@@ -253,7 +256,8 @@ int dentry_set_symlink(struct dentry *dentry, const char *target,
                *lte_ret = lte;
        return 0;
 out_free_lte:
-       FREE(lte);
+       if (lte != existing_lte)
+               FREE(lte);
 out_free_symlink_buf:
        FREE(symlink_buf);
        return ret;