Skip to content

Commit

Permalink
[kvdb] fix null-pointer dereference (#314)
Browse files Browse the repository at this point in the history
The C library function - strlen() does not accept a null-pointer.

Signed-off-by: FragrantRye <903465575@qq.com>
  • Loading branch information
FragrantRye authored Sep 15, 2024
1 parent 523fd20 commit fd08d7f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/fdb_kvdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,11 @@ fdb_err_t fdb_kv_set(fdb_kvdb_t db, const char *key, const char *value)
{
struct fdb_blob blob;

return fdb_kv_set_blob(db, key, fdb_blob_make(&blob, value, strlen(value)));
if (value) {
return fdb_kv_set_blob(db, key, fdb_blob_make(&blob, value, strlen(value)));
} else {
return fdb_kv_del(db, key);
}
}

/**
Expand Down

0 comments on commit fd08d7f

Please sign in to comment.