2024-09-21 06:56 BST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002881NetSurf[All Projects] Generalpublic2024-09-11 09:49
ReporterPeter Strath 
Assigned To 
SeveritycrashReproducibilityalways 
StatusresolvedResolutionopen 
Platformamd64OSlinuxOS Versiongtk3, X11
Product Version3.11 
Target Version3.12Fixed in Version3.12 
Summary0002881: Crash in treeview after pressing left or right cursor keys
DescriptionCursor key navigation in a treeview without any previously selected node results in a crash.

Crash reproduced in both 3.11 and latest git update.
Steps To Reproduce- ./nsgtk3
- F6 to open new bookmarks window (or any window with a treeview)
- press either left or right cursor keys (or any cursor key if treeview is empty)
Additional Information(gdb) bt
#0 0x0000559ded6d9d00 in treeview__cw_scroll_to_node (tree=0x559e11204650, node=0x0) at desktop/treeview.c:603
#1 treeview_keyboard_navigation (tree=0x559e11204650, key=29, rect=0x7fffa8b106e0) at desktop/treeview.c:3989
0000002 treeview_keypress (tree=0x559e11204650, key=29) at desktop/treeview.c:4076
#3 0x0000559ded6c5822 in hotlist_keypress (key=<optimized out>) at desktop/hotlist.c:1699
...

I've attached a patch that prevents this crash for me.
TagsNo tags attached.
Fixed in CI build #6757
Reported in CI build #
URL of problem page
Attached Files
  • diff file icon fix-crash-on-cursor-keys-in-treeview.diff (1,286 bytes) 2024-08-30 16:58 -
    diff --git a/desktop/treeview.c b/desktop/treeview.c
    index 107f490e0..04663dc5b 100644
    --- a/desktop/treeview.c
    +++ b/desktop/treeview.c
    @@ -595,6 +595,10 @@ static inline void treeview__cw_scroll_to_node(
     		const struct treeview *tree,
     		const struct treeview_node *node)
     {
    +	if (node == NULL) {
    +		return;
    +	}
    +
     	struct rect r = {
     		.x0 = 0,
     		.y0 = treeview_node_y(tree, node),
    @@ -3932,7 +3936,7 @@ treeview_keyboard_navigation(treeview *tree, uint32_t key, struct rect *rect)
     			ns.curr->parent->flags |= TV_NFLAGS_SELECTED;
     			scroll_to_node = ns.curr->parent;
     
    -		} else if (ns.curr != NULL && tree->root->children != NULL) {
    +		} else if (tree->root->children != NULL) {
     			/* Select first node in tree */
     			tree->root->children->flags |= TV_NFLAGS_SELECTED;
     			scroll_to_node = tree->root->children;
    @@ -3960,9 +3964,10 @@ treeview_keyboard_navigation(treeview *tree, uint32_t key, struct rect *rect)
     				ns.curr->flags |= TV_NFLAGS_SELECTED;
     			}
     
    -		} else if (ns.curr != NULL) {
    -			/* Retain current node selection */
    -			ns.curr->flags |= TV_NFLAGS_SELECTED;
    +		} else if (tree->root->children != NULL) {
    +			/* Select first node in tree */
    +			tree->root->children->flags |= TV_NFLAGS_SELECTED;
    +			scroll_to_node = tree->root->children;
     		}
     		break;
     
    
    diff file icon fix-crash-on-cursor-keys-in-treeview.diff (1,286 bytes) 2024-08-30 16:58 +

-Relationships
+Relationships

-Notes
Vincent Sanders

~0002467

Vincent Sanders (administrator)

Thank you for the report.

This has been resolved in commit https://git.netsurf-browser.org/netsurf.git/commit/?id=a9f13decf47f43d97a7aaf48af441ef82c8dd2cd

This commit will be in the 3.12 release.
+Notes

-Issue History
Date Modified Username Field Change
2024-08-30 16:58 Peter Strath New Issue
2024-08-30 16:58 Peter Strath File Added: fix-crash-on-cursor-keys-in-treeview.diff
2024-09-11 09:49 Vincent Sanders Status new => resolved
2024-09-11 09:49 Vincent Sanders Fixed in Version => 3.12
2024-09-11 09:49 Vincent Sanders Target Version => 3.12
2024-09-11 09:49 Vincent Sanders Fixed in CI build # => 6757
2024-09-11 09:49 Vincent Sanders Note Added: 0002467
+Issue History