From: Tom Lane Date: Wed, 19 Feb 2025 02:23:59 +0000 (-0500) Subject: Avoid null pointer dereference crash after OOM in Snowball stemmers. X-Git-Tag: REL_14_18~73 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=8388cae5526b39dea40e35c14b7bc93cae5cb321;p=postgresql.git Avoid null pointer dereference crash after OOM in Snowball stemmers. Absorb upstream bug fix (their commit e322673a841d9abd69994ae8cd20e191090b6ef4), which prevents a null pointer dereference crash if SN_create_env() gets a malloc failure at just the wrong point. Thanks to Maksim Korotkov for discovering the null-pointer bug and submitting the fix to upstream snowball. Reported-by: Maksim Korotkov Author: Maksim Korotkov Discussion: https://postgr.es/m/1d1a46-67ab1000-21-80c451@83151435 Backpatch-through: 13 --- diff --git a/src/backend/snowball/libstemmer/api.c b/src/backend/snowball/libstemmer/api.c index 375938e6d13..358f5633b28 100644 --- a/src/backend/snowball/libstemmer/api.c +++ b/src/backend/snowball/libstemmer/api.c @@ -34,7 +34,7 @@ error: extern void SN_close_env(struct SN_env * z, int S_size) { if (z == NULL) return; - if (S_size) + if (z->S) { int i; for (i = 0; i < S_size; i++)