Skip to content

Commit 155f11e

Browse files
committed
Add bounds check for chan_buttons array access
Prevents "gtk_widget_set_name: assertion 'GTK_IS_WIDGET (widget)' failed" in terminal. When clicking on the scope background, the channel index becomes -1.
1 parent 34672df commit 155f11e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/hal/utils/scope_vert.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,11 +1085,11 @@ void channel_changed(void)
10851085
vert = &(ctrl_usr->vert);
10861086
/* add a name to apply CSS for highlighted channel */
10871087
if (last_channel != vert->selected) {
1088-
if (last_channel) {
1089-
gtk_widget_set_name(chan_buttons[last_channel-1],"");
1088+
if ((last_channel >= 1) && (last_channel <= 16)) {
1089+
gtk_widget_set_name(chan_buttons[last_channel - 1], "");
10901090
}
1091-
if (vert->selected) {
1092-
gtk_widget_set_name(chan_buttons[vert->selected-1],"selected");
1091+
if ((vert->selected >= 1) && (vert->selected <= 16)) {
1092+
gtk_widget_set_name(chan_buttons[vert->selected - 1], "selected");
10931093
}
10941094
last_channel = vert->selected;
10951095
}

0 commit comments

Comments
 (0)