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)
ret = corrupt_or_copy(in, inl, ©, ©len);
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;
}