X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb1_check.c;h=a8e54b2ee092f4cb7e1866818551e4e6177f1e5b;hb=20f3b260313fb4d5566aeb0d0c5439574e914e2d;hp=4d71712c473fb465021ca0cd778dc3b9bbdad418;hpb=ef92843f2c74ab9d4fa7f167a2182e5e8955df91;p=ccan diff --git a/ccan/tdb2/tdb1_check.c b/ccan/tdb2/tdb1_check.c index 4d71712c..a8e54b2e 100644 --- a/ccan/tdb2/tdb1_check.c +++ b/ccan/tdb2/tdb1_check.c @@ -339,6 +339,7 @@ int tdb1_check(struct tdb_context *tdb, bool found_recovery = false; tdb1_len_t dead; bool locked; + size_t alloc_len; /* We may have a write lock already, so don't re-lock. */ if (tdb->file->allrecord_lock.count != 0) { @@ -364,11 +365,13 @@ int tdb1_check(struct tdb_context *tdb, } /* One big malloc: pointers then bit arrays. */ - hashes = (unsigned char **)calloc( - 1, sizeof(hashes[0]) * (1+tdb->tdb1.header.hash_size) - + BITMAP_BITS / CHAR_BIT * (1+tdb->tdb1.header.hash_size)); + alloc_len = sizeof(hashes[0]) * (1+tdb->tdb1.header.hash_size) + + BITMAP_BITS / CHAR_BIT * (1+tdb->tdb1.header.hash_size); + hashes = (unsigned char **)calloc(1, alloc_len); if (!hashes) { - tdb->last_error = TDB_ERR_OOM; + tdb->last_error = tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR, + "tdb_check: could not allocate %zu", + alloc_len); goto unlock; }