summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2023-05-05 16:46:42 +0200
committerHugo Landau <hlandau@openssl.org>2023-05-17 14:04:17 +0100
commitdbca844cb3e74b19acf46eb9a2222d30802ad642 (patch)
tree1e75f815aa2964539e91fbb91143cb671f863b67
parent4b4e246ccb6e32de9aaf228c8f9ee415ede4b612 (diff)
downloadopenssl-new-dbca844cb3e74b19acf46eb9a2222d30802ad642.tar.gz
quic_txp_test.c: Cleanup use of WPACKET
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20892)
-rw-r--r--test/quic_txp_test.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/test/quic_txp_test.c b/test/quic_txp_test.c
index 1d71721a6c..e01156d156 100644
--- a/test/quic_txp_test.c
+++ b/test/quic_txp_test.c
@@ -391,7 +391,6 @@ static int schedule_cfq_new_conn_id(struct helper *h)
QUIC_CFQ_ITEM *cfq_item;
WPACKET wpkt;
BUF_MEM *buf_mem = NULL;
- char have_wpkt = 0;
size_t l = 0;
OSSL_QUIC_FRAME_NEW_CONN_ID ncid = {0};
@@ -406,9 +405,12 @@ static int schedule_cfq_new_conn_id(struct helper *h)
if (!TEST_true(WPACKET_init(&wpkt, buf_mem)))
goto err;
- have_wpkt = 1;
- if (!TEST_true(ossl_quic_wire_encode_frame_new_conn_id(&wpkt, &ncid)))
+ if (!TEST_true(ossl_quic_wire_encode_frame_new_conn_id(&wpkt, &ncid))) {
+ WPACKET_cleanup(&wpkt);
goto err;
+ }
+
+ WPACKET_finish(&wpkt);
if (!TEST_true(WPACKET_get_total_written(&wpkt, &l)))
goto err;
@@ -423,8 +425,8 @@ static int schedule_cfq_new_conn_id(struct helper *h)
rc = 1;
err:
- if (have_wpkt)
- WPACKET_cleanup(&wpkt);
+ if (!rc)
+ BUF_MEM_free(buf_mem);
return rc;
}
@@ -470,7 +472,6 @@ static int schedule_cfq_new_token(struct helper *h)
QUIC_CFQ_ITEM *cfq_item;
WPACKET wpkt;
BUF_MEM *buf_mem = NULL;
- char have_wpkt = 0;
size_t l = 0;
if (!TEST_ptr(buf_mem = BUF_MEM_new()))
@@ -479,10 +480,13 @@ static int schedule_cfq_new_token(struct helper *h)
if (!TEST_true(WPACKET_init(&wpkt, buf_mem)))
goto err;
- have_wpkt = 1;
if (!TEST_true(ossl_quic_wire_encode_frame_new_token(&wpkt, token_1,
- sizeof(token_1))))
+ sizeof(token_1)))) {
+ WPACKET_cleanup(&wpkt);
goto err;
+ }
+
+ WPACKET_finish(&wpkt);
if (!TEST_true(WPACKET_get_total_written(&wpkt, &l)))
goto err;
@@ -497,8 +501,8 @@ static int schedule_cfq_new_token(struct helper *h)
rc = 1;
err:
- if (have_wpkt)
- WPACKET_cleanup(&wpkt);
+ if (!rc)
+ BUF_MEM_free(buf_mem);
return rc;
}