Lock before checking the statement pool (#20536)
Stelios Fragkakis committed
Jun 20, 2025 at 16:19 UTC
32e2801cc27ac40b21b479be819d0ceea072f0ef
1 file changed
+6
-6
src/database/sqlite/sqlite_functions.c
+6
-6
@@ -189,13 +189,13 @@ static void finalize_and_free_stmt_list(struct stmt_pool_s *stmt_list)
189
// This must be called when the thread terminates
190
void finalize_self_prepared_sql_statements()
191
{
192
- if (!thread_stmt_pool)
193
- return;
192
spinlock_lock(&JudyL_thread_stmt_lock);
195
- Word_t thread_id = thread_stmt_pool->thread_id;
196
- finalize_and_free_stmt_list(thread_stmt_pool);
197
- thread_stmt_pool = NULL;
198
- (void) JudyLDel(&JudyL_thread_stmt_pool, thread_id, PJE0);
193
+ if (thread_stmt_pool) {
194
+ Word_t thread_id = thread_stmt_pool->thread_id;
195
+ finalize_and_free_stmt_list(thread_stmt_pool);
196
+ thread_stmt_pool = NULL;
197
+ (void)JudyLDel(&JudyL_thread_stmt_pool, thread_id, PJE0);
198
+ }
199
spinlock_unlock(&JudyL_thread_stmt_lock);
200
}
201