This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-native.git
The following commit(s) were added to refs/heads/main by this push:
new c5a097a8c Harden against the mis-use of Pool.destroy(long)
c5a097a8c is described below
commit c5a097a8c9281b6025f7dcb0976ea442fb081f4b
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Aug 28 18:57:28 2026 +0100
Harden against the mis-use of Pool.destroy(long)
---
native/src/pool.c | 11 ++++++++++-
xdocs/miscellaneous/changelog.xml | 3 +++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/native/src/pool.c b/native/src/pool.c
index 45df89b23..a7076b9f8 100644
--- a/native/src/pool.c
+++ b/native/src/pool.c
@@ -36,7 +36,16 @@ TCN_IMPLEMENT_CALL(void, Pool, destroy)(TCN_STDARGS, jlong
pool)
{
apr_pool_t *p = J2P(pool, apr_pool_t *);
UNREFERENCED_STDARGS;
- TCN_ASSERT(pool != 0);
+
+ if (pool == 0) {
+ jclass npe = (*e)->FindClass(e, "java/lang/NullPointerException");
+ if (npe != NULL) {
+ (*e)->ThrowNew(e, npe, "Pool must not be zero");
+ (*e)->DeleteLocalRef(e, npe);
+ }
+ return;
+ }
+
if (tcn_global_pool)
apr_pool_destroy(p);
}
diff --git a/xdocs/miscellaneous/changelog.xml
b/xdocs/miscellaneous/changelog.xml
index 347d98cca..24ff3bac9 100644
--- a/xdocs/miscellaneous/changelog.xml
+++ b/xdocs/miscellaneous/changelog.xml
@@ -91,6 +91,9 @@
Harden against the mis-use of <code>Buffer.address(ByteBuffer)</code>.
(markt)
</fix>
+ <fix>
+ Harden against the mis-use of <code>Pool.destroy(long)</code>. (markt)
+ </fix>
</changelog>
</section>
<section name="2.0.15" rtext="2026-06-15">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]