]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/ech_corrupt_test.c: avoid memory leak in tls_corrupt_write()
authorEugene Syromiatnikov <esyr@openssl.org>
Mon, 23 Feb 2026 05:39:29 +0000 (06:39 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 25 Feb 2026 11:10:24 +0000 (12:10 +0100)
corrupt_or_copy() may return 0 while still setting returning the allocated
memory in copy, avoid leaking it by always calling OPENSSL_free() on it.

Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1681460
Fixes: 5e5a76fc2c08 "Add tests and documentation and fix a couple of issues identified by added tests"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Wed Feb 25 11:10:57 2026
(Merged from https://github.com/openssl/openssl/pull/30139)

test/ech_corrupt_test.c

index 2c68d49c4cdb33f586f9d2eb2103250b4b2c589c..28b681ed08da5e6fcdfa05974255699410b25f5d 100644 (file)
@@ -1282,10 +1282,11 @@ static int tls_corrupt_write(BIO *bio, const char *in, int inl)
 
     ret = corrupt_or_copy(in, inl, &copy, &copylen);
     if (ret == 0)
-        return 0;
+        goto out;
     ret = BIO_write(next, copy, inl);
-    OPENSSL_free(copy);
     copy_flags(bio);
+out:
+    OPENSSL_free(copy);
     return ret;
 }