From 130d6f9c4bfaa63b2156eef7fe5ca0ffa27554af Mon Sep 17 00:00:00 2001
From: Monty <monty@mariadb.org>
Date: Sat, 28 Dec 2024 11:06:04 +0200
Subject: [PATCH] Fixed memory leak in get_window_functions_required_cursors()

Found by buildbot with test main.gis
---
 sql/sql_window.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 816d49a1a65..7beba09387f 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -2726,7 +2726,10 @@ bool get_window_functions_required_cursors(
         item_win_func->requires_special_cursors())
     {
       if (add_special_frame_cursors(thd, cursor_manager, item_win_func))
+      {
+        delete cursor_manager;
         return true;
+      }
       cursor_managers->push_back(cursor_manager);
       continue;
     }