From fd08d7f3230482aa655fe4cd525f99e1b7e6f4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E8=8B=A5=E9=BA=A6=E9=A6=99?= <903465575@qq.com> Date: Sun, 15 Sep 2024 16:32:07 +0800 Subject: [PATCH] [kvdb] fix null-pointer dereference (#314) The C library function - strlen() does not accept a null-pointer. Signed-off-by: FragrantRye <903465575@qq.com> --- src/fdb_kvdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fdb_kvdb.c b/src/fdb_kvdb.c index 00cf557..17a4c46 100644 --- a/src/fdb_kvdb.c +++ b/src/fdb_kvdb.c @@ -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); + } } /**