]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/free.c
tdb2: new tests, and new fixes.
[ccan] / ccan / tdb2 / free.c
index be2b91f1dec0a988c539e3dc2b86874fe53e9b7d..0b724f23cce7c6fc239e630c5f44b027e461d177 100644 (file)
@@ -279,7 +279,7 @@ static int coalesce(struct tdb_context *tdb, tdb_off_t off,
                        break;
                }
 
-               if (remove_from_list(tdb, list, r) == -1) {
+               if (remove_from_list(tdb, nlist, r) == -1) {
                        tdb_unlock_free_list(tdb, nlist);
                        goto err;
                }
@@ -297,6 +297,14 @@ static int coalesce(struct tdb_context *tdb, tdb_off_t off,
        if (!r)
                goto err;
 
+       if (r->data_len != data_len) {
+               tdb->ecode = TDB_ERR_CORRUPT;
+               tdb->log(tdb, TDB_DEBUG_FATAL, tdb->log_priv,
+                        "coalesce: expected data len %llu not %llu\n",
+                        (long long)data_len, (long long)r->data_len);
+               goto err;
+       }
+
        if (remove_from_list(tdb, list, r) == -1)
                goto err;