@@ -198,7 +198,9 @@ static int parse(struct ldb_val key, struct ldb_val data, void *private_data)
198198{
199199 struct ldb_val * read = private_data ;
200200
201- /* Yes, we leak this. That is OK */
201+ /*
202+ * This should not leak if possible, please check with Leak Sanitizer.
203+ */
202204 read -> data = talloc_size (NULL , data .length );
203205 assert_non_null (read -> data );
204206
@@ -218,8 +220,8 @@ static void test_free_list_no_read_lock(void **state)
218220 struct test_ctx * test_ctx =
219221 talloc_get_type_abort (* state , struct test_ctx );
220222 struct ldb_kv_private * ldb_kv = get_ldb_kv (test_ctx -> ldb );
221- struct ldb_val key ;
222- struct ldb_val val ;
223+ struct ldb_val key = {} ;
224+ struct ldb_val val = {} ;
223225
224226 const char * KEY1 = "KEY01" ;
225227
@@ -341,6 +343,7 @@ static void test_free_list_no_read_lock(void **state)
341343
342344 ret = ldb_kv -> kv_ops -> fetch_and_parse (ldb_kv , key , parse , & val );
343345 assert_int_equal (ret , LDB_SUCCESS );
346+ TALLOC_FREE (val .data );
344347
345348 ret = ldb_kv -> kv_ops -> unlock_read (test_ctx -> ldb -> modules );
346349 assert_int_equal (ret , LDB_SUCCESS );
@@ -361,8 +364,8 @@ static void test_free_list_read_lock(void **state)
361364 struct test_ctx * test_ctx =
362365 talloc_get_type_abort (* state , struct test_ctx );
363366 struct ldb_kv_private * ldb_kv = get_ldb_kv (test_ctx -> ldb );
364- struct ldb_val key ;
365- struct ldb_val val ;
367+ struct ldb_val key = {} ;
368+ struct ldb_val val = {} ;
366369
367370 const char * KEY1 = "KEY01" ;
368371
@@ -450,6 +453,7 @@ static void test_free_list_read_lock(void **state)
450453
451454 ret = ldb_kv -> kv_ops -> fetch_and_parse (ldb_kv , key , parse , & val );
452455 assert_int_equal (ret , LDB_SUCCESS );
456+ TALLOC_FREE (val .data );
453457
454458 ret = ldb_kv -> kv_ops -> unlock_read (ldb -> modules );
455459 assert_int_equal (ret , LDB_SUCCESS );
@@ -492,6 +496,7 @@ static void test_free_list_read_lock(void **state)
492496
493497 ret = ldb_kv -> kv_ops -> fetch_and_parse (ldb_kv , key , parse , & val );
494498 assert_int_equal (ret , LDB_ERR_NO_SUCH_OBJECT );
499+ TALLOC_FREE (val .data );
495500 ret = ldb_kv -> kv_ops -> unlock_read (test_ctx -> ldb -> modules );
496501 assert_int_equal (ret , 0 );
497502
@@ -510,8 +515,8 @@ static void test_free_list_stale_reader(void **state)
510515 struct test_ctx * test_ctx =
511516 talloc_get_type_abort (* state , struct test_ctx );
512517 struct ldb_kv_private * ldb_kv = get_ldb_kv (test_ctx -> ldb );
513- struct ldb_val key ;
514- struct ldb_val val ;
518+ struct ldb_val key = {} ;
519+ struct ldb_val val = {} ;
515520
516521 const char * KEY1 = "KEY01" ;
517522
@@ -639,6 +644,7 @@ static void test_free_list_stale_reader(void **state)
639644
640645 ret = ldb_kv -> kv_ops -> fetch_and_parse (ldb_kv , key , parse , & val );
641646 assert_int_equal (ret , LDB_SUCCESS );
647+ TALLOC_FREE (val .data );
642648
643649 ret = ldb_kv -> kv_ops -> unlock_read (test_ctx -> ldb -> modules );
644650 assert_int_equal (ret , LDB_SUCCESS );
0 commit comments