This prevents a potential crash if `sidebar_update_tag_list()` is called with update=true and document=NULL.
Found this by accident while testing the tag tree filter PR. Currently, this is no problem as `sidebar_update_tag_list()` is not called with update=true and document=NULL but just in case it might happen. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3080
-- Commit Summary --
* Update doc->priv->tag_tree_dirty only if doc is set
-- File Changes --
M src/sidebar.c (2)
-- Patch Links --
https://github.com/geany/geany/pull/3080.patch https://github.com/geany/geany/pull/3080.diff
@elextr approved this pull request.
ignore spurious comment, is ok
@@ -191,7 +191,7 @@ void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
g_return_if_fail(doc == NULL || doc->is_valid);
Maybe this should be doc != NULL?
@@ -191,7 +191,7 @@ void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
g_return_if_fail(doc == NULL || doc->is_valid);
erm, no, its or not and, please ignore
@techee commented on this pull request.
@@ -191,7 +191,7 @@ void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
g_return_if_fail(doc == NULL || doc->is_valid);
Yeah, it should be `doc != NULL && doc->is_valid` I think.
@elextr commented on this pull request.
@@ -191,7 +191,7 @@ void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
g_return_if_fail(doc == NULL || doc->is_valid);
Nah, I made that mistake first too, but doc == NULL has to keep going to remove the tag tree if there is no doc
@techee commented on this pull request.
@@ -191,7 +191,7 @@ void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
g_return_if_fail(doc == NULL || doc->is_valid);
Ah, OK, got it now too, it's correct.
@techee commented on this pull request.
@@ -191,7 +191,7 @@ void sidebar_update_tag_list(GeanyDocument *doc, gboolean update)
g_return_if_fail(doc == NULL || doc->is_valid);
- if (update) + if (update && doc != NULL)
Definitely good to add, this code was actually written by me and I think I just fell into the misunderstanding of the `g_return_if_fail()` trap above.
Merged #3080 into master.
github-comments@lists.geany.org