]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-cdb: Handle cdb_read() errors.
authorTimo Sirainen <tss@iki.fi>
Mon, 21 Jan 2013 16:33:55 +0000 (18:33 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 21 Jan 2013 16:33:55 +0000 (18:33 +0200)
src/lib-dict/dict-cdb.c

index ea9ee13e57cbb06b0383be7c43457f92c03ab0e3..41f226786b87105cffc9de6d5bfbec3a229cf5c9 100644 (file)
@@ -102,7 +102,7 @@ static int cdb_dict_lookup(struct dict *_dict, pool_t pool,
                *value_r = NULL;
                /* something bad with db */
                if (ret < 0) {
-                       i_error("cdb_lookup(%s) failed: %m", dict->path);
+                       i_error("cdb_find(%s) failed: %m", dict->path);
                        return -1;
                }
                /* found nothing */
@@ -110,8 +110,11 @@ static int cdb_dict_lookup(struct dict *_dict, pool_t pool,
        }
 
        datalen = cdb_datalen(&dict->cdb);
-       data = p_new(pool, char, datalen + 1);
-       cdb_read(&dict->cdb, data, datalen, cdb_datapos(&dict->cdb));
+       data = p_malloc(pool, datalen + 1);
+       if (cdb_read(&dict->cdb, data, datalen, cdb_datapos(&dict->cdb)) < 0) {
+               i_error("cdb_read(%s) failed: %m", dict->path);
+               return -1;
+       }
        *value_r = data;
        return 1;
 }