diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-12-01 16:53:21 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-12-01 16:53:27 +0100 |
| commit | 96730f80cbc3b2d5aec2967a61f16bb2f02853e6 (patch) | |
| tree | 2efb7ea0cf9f9f71aa7fa1838bd4b349ff9157d2 /fluid | |
| parent | ccc21d381a41620a9fb91870ab2a47ef9309d148 (diff) | |
Adds some possible NULL references and small fixes
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/Fl_Grid_Type.cxx | 33 | ||||
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 6 | ||||
| -rw-r--r-- | fluid/factory.cxx | 3 | ||||
| -rw-r--r-- | fluid/shell_command.cxx | 4 |
4 files changed, 24 insertions, 22 deletions
diff --git a/fluid/Fl_Grid_Type.cxx b/fluid/Fl_Grid_Type.cxx index 6621a2f03..b27a8be7c 100644 --- a/fluid/Fl_Grid_Type.cxx +++ b/fluid/Fl_Grid_Type.cxx @@ -187,7 +187,11 @@ Fl_Grid::Cell* Fl_Grid_Proxy::transient_widget(Fl_Widget *wi, int row, int col, int mw, mh; old_cell->minimum_size(&mw, &mh); new_cell->minimum_size(mw, mh); - ::free(old_cell); + if (remove_old_cell) { + remove_cell(old_cell->row(), old_cell->col()); + } else { + delete old_cell; + } } if (i == num_transient_) { transient_make_room_(num_transient_ + 1); @@ -195,9 +199,6 @@ Fl_Grid::Cell* Fl_Grid_Proxy::transient_widget(Fl_Widget *wi, int row, int col, num_transient_++; } transient_[i].cell = new_cell; - if (remove_old_cell) { - remove_cell(old_cell->row(), old_cell->col()); - } return new_cell; } @@ -911,12 +912,12 @@ void grid_align_horizontal_cb(Fl_Choice* i, void* v) { Fl_Grid::Cell *cell = g->cell(current_widget->o); if (cell) { old_v = cell->align() & mask; - } - if (old_v != v) { - cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask))); - g->need_layout(true); - g->redraw(); - set_modflag(1); + if (old_v != v) { + cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask))); + g->need_layout(true); + g->redraw(); + set_modflag(1); + } } } } @@ -946,12 +947,12 @@ void grid_align_vertical_cb(Fl_Choice* i, void* v) { Fl_Grid::Cell *cell = g->cell(current_widget->o); if (cell) { old_v = cell->align() & mask; - } - if (old_v != v) { - cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask))); - g->need_layout(true); - g->redraw(); - set_modflag(1); + if (old_v != v) { + cell->align((Fl_Grid_Align)(v | (cell->align() & ~mask))); + g->need_layout(true); + g->redraw(); + set_modflag(1); + } } } } diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 05260136c..9a5c3251a 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -3659,9 +3659,9 @@ void Fl_Widget_Type::copy_properties() { if (!live_widget) return; - Fl_Font ff; - int fs; - Fl_Color fc; + Fl_Font ff = 0; + int fs = 0; + Fl_Color fc = 0; textstuff(0, ff, fs, fc); // copy all attributes common to all widget types diff --git a/fluid/factory.cxx b/fluid/factory.cxx index a60717e30..59a358bce 100644 --- a/fluid/factory.cxx +++ b/fluid/factory.cxx @@ -1243,7 +1243,8 @@ Fl_Type *add_new_widget_from_user(Fl_Type *inPrototype, Strategy strategy) { if (changed && t->is_a(ID_Menu_Item)) { Fl_Type * tt = t->parent; while (tt && !tt->is_a(ID_Menu_Manager_)) tt = tt->parent; - ((Fl_Menu_Manager_Type*)tt)->build_menu(); + if (tt) + ((Fl_Menu_Manager_Type*)tt)->build_menu(); } } if (t->is_true_widget() && !t->is_a(ID_Window)) { diff --git a/fluid/shell_command.cxx b/fluid/shell_command.cxx index 1af872ae0..79b1609e8 100644 --- a/fluid/shell_command.cxx +++ b/fluid/shell_command.cxx @@ -795,7 +795,7 @@ void Fd_Shell_Command_List::write(Fd_Project_Writer *out) { void Fd_Shell_Command_List::add(Fd_Shell_Command *cmd) { if (list_size == list_capacity) { list_capacity += 16; - list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command**)); + list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command*)); } list[list_size++] = cmd; } @@ -809,7 +809,7 @@ void Fd_Shell_Command_List::add(Fd_Shell_Command *cmd) { void Fd_Shell_Command_List::insert(int index, Fd_Shell_Command *cmd) { if (list_size == list_capacity) { list_capacity += 16; - list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command**)); + list = (Fd_Shell_Command**)::realloc(list, list_capacity * sizeof(Fd_Shell_Command*)); } ::memmove(list+index+1, list+index, (list_size-index)*sizeof(Fd_Shell_Command**)); list_size++; |
