tdb2: rework some io.c functions to encode errors in their pointer returns.
[ccan] / ccan / tdb2 / tdb.c
index 8079dad7887d89a649d3ec8aa67daf215d0af041..130bb6b594f687ea81cd3ed59b223dcaf861b8bc 100644 (file)
@@ -631,6 +631,10 @@ struct tdb_data tdb_fetch(struct tdb_context *tdb, struct tdb_data key)
                ret.dsize = rec_data_length(&rec);
                ret.dptr = tdb_alloc_read(tdb, off + sizeof(rec) + key.dsize,
                                          ret.dsize);
+               if (TDB_PTR_IS_ERR(ret.dptr)) {
+                       tdb->ecode = TDB_PTR_ERR(ret.dptr);
+                       ret = tdb_null;
+               }
        }
 
        tdb_unlock_hashes(tdb, h.hlock_start, h.hlock_range, F_RDLCK);