diff --git a/libraries/liblmdb/mdb_dump.c b/libraries/liblmdb/mdb_dump.c index ee7dbe85d8..63b08d658d 100644 --- a/libraries/liblmdb/mdb_dump.c +++ b/libraries/liblmdb/mdb_dump.c @@ -279,6 +279,10 @@ int main(int argc, char *argv[]) continue; count++; str = malloc(key.mv_size+1); + if (!str) { + fprintf(stderr, "malloc failed\n"); + goto txn_abort; + } memcpy(str, key.mv_data, key.mv_size); str[key.mv_size] = '\0'; rc = mdb_open(txn, str, 0, &db2); diff --git a/libraries/liblmdb/mdb_stat.c b/libraries/liblmdb/mdb_stat.c index cb73e11322..f64475efe6 100644 --- a/libraries/liblmdb/mdb_stat.c +++ b/libraries/liblmdb/mdb_stat.c @@ -232,6 +232,10 @@ int main(int argc, char *argv[]) if (memchr(key.mv_data, '\0', key.mv_size)) continue; str = malloc(key.mv_size+1); + if (!str) { + fprintf(stderr, "malloc failed\n"); + goto txn_abort; + } memcpy(str, key.mv_data, key.mv_size); str[key.mv_size] = '\0'; rc = mdb_open(txn, str, 0, &db2);