From 9952017a03772825877e7103a36255cdcc2ffac8 Mon Sep 17 00:00:00 2001 From: Herman Semenoff Date: Sun, 12 Jul 2026 14:51:08 +0300 Subject: [PATCH] Fix unverified realloc (#1486) * temporary fix --- src/Fl.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Fl.cxx b/src/Fl.cxx index 22196316c..5998afde4 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -2014,7 +2014,14 @@ void Fl::watch_widget_pointer(Fl_Widget *&w) } if (num_widget_watch==max_widget_watch) { max_widget_watch += 8; - widget_watch = (Fl_Widget***)realloc(widget_watch, sizeof(Fl_Widget**)*max_widget_watch); + Fl_Widget*** new_widget_watch = (Fl_Widget***)realloc(widget_watch, sizeof(Fl_Widget**)*max_widget_watch); + if (new_widget_watch) { + widget_watch = new_widget_watch; + } else { + // realloc failed, original widget_watch is still valid. + // Return to avoid using a potentially invalid pointer. + return; + } } widget_watch[num_widget_watch++] = wp; #ifdef DEBUG_WATCH