diff --git a/apps/openssl.c b/apps/openssl.c index a3056c799f85706446575a6acbecb0672c71e62b..fafda12194426bee25310f9ea3458372b0487c28 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -190,6 +190,7 @@ static void setup_trace_category(int category) OSSL_trace_set_callback(category, NULL, NULL); BIO_free_all(channel); + OPENSSL_free(trace_data); } } diff --git a/crypto/params_dup.c b/crypto/params_dup.c index bc1546fc53cb5621d1c954efe09a6f6842b1e619..5335eb6bbdd70a5378a0158f5d935e014c677230 100644 --- a/crypto/params_dup.c +++ b/crypto/params_dup.c @@ -189,18 +189,18 @@ OSSL_PARAM *OSSL_PARAM_merge(const OSSL_PARAM *p1, const OSSL_PARAM *p2) while (1) { /* If list1 is finished just tack list2 onto the end */ if (*p1cur == NULL) { - do { + while (*p2cur != NULL) { *dst++ = **p2cur; p2cur++; - } while (*p2cur != NULL); + } break; } /* If list2 is finished just tack list1 onto the end */ if (*p2cur == NULL) { - do { + while (*p1cur != NULL) { *dst++ = **p1cur; p1cur++; - } while (*p1cur != NULL); + } break; } /* consume the list element with the smaller key */ diff --git a/test/params_api_test.c b/test/params_api_test.c index 48e2f8920aa28157ed3a0d2f2219d593596cb6ab..1cebd67ff755d2384e43fee9ac7cc1fd54f5f4bb 100644 --- a/test/params_api_test.c +++ b/test/params_api_test.c @@ -692,6 +692,33 @@ static int test_param_copy_null(void) OSSL_PARAM_free(cp1); return ret; } +static int test_param_merge(void) +{ + int val, ret; + int values[] = {1, 2, 3, 4}; + OSSL_PARAM *p = NULL, *cp = NULL; + OSSL_PARAM param[3], param1[3]; + + param[0] = OSSL_PARAM_construct_int("diff1", &values[0]); + param[1] = OSSL_PARAM_construct_int("same", &values[1]); + param[2] = OSSL_PARAM_construct_end(); + param1[0] = OSSL_PARAM_construct_int("diff2", &values[2]); + param1[1] = OSSL_PARAM_construct_int("same", &values[3]); + param1[2] = OSSL_PARAM_construct_end(); + + ret = TEST_ptr(p = OSSL_PARAM_merge(param, param1)) + && TEST_ptr(cp = OSSL_PARAM_locate(p, "diff1")) + && TEST_true(OSSL_PARAM_get_int(p, &val)) + && TEST_int_eq(val, values[0]) + && TEST_ptr(cp = OSSL_PARAM_locate(p, "diff2")) + && TEST_true(OSSL_PARAM_get_int(cp, &val)) + && TEST_int_eq(val, values[2]) + && TEST_ptr(cp = OSSL_PARAM_locate(p, "same")) + && TEST_true(OSSL_PARAM_get_int(cp, &val)) + && TEST_int_eq(val, values[3]); + OSSL_PARAM_free(p); + return ret; +} int setup_tests(void) { @@ -710,5 +737,6 @@ int setup_tests(void) ADD_ALL_TESTS(test_param_construct, 4); ADD_TEST(test_param_modified); ADD_TEST(test_param_copy_null); + ADD_TEST(test_param_merge); return 1; }