Skip to content

Commit

Permalink
pairtaghighliter: Fix crash on plugin unload
Browse files Browse the repository at this point in the history
Fix crash on plugin unload if the plugin didn't run on any editor, or
if the last editor it ran on became invalid.

The global 'sci' variable wasn't set in 'plugin_cleanup()' and thus may
either have been uninitialized or initialized to a value not valid
anymore.

The simplest way to reproduce the crash was to load and then
immediately unload the plugin, without leaving the plugin manager
dialog.
  • Loading branch information
b4n committed May 9, 2013
1 parent 37ecd6a commit fdcf8f8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pairtaghighlighter/src/pair_tag_highlighter.c
Expand Up @@ -344,6 +344,12 @@ void plugin_init(GeanyData *data)

void plugin_cleanup(void)
{
clear_previous_highlighting(highlightedBrackets[0], highlightedBrackets[1]);
clear_previous_highlighting(highlightedBrackets[2], highlightedBrackets[3]);
GeanyDocument *doc = document_get_current();

if (doc)
{
sci = doc->editor->sci;
clear_previous_highlighting(highlightedBrackets[0], highlightedBrackets[1]);
clear_previous_highlighting(highlightedBrackets[2], highlightedBrackets[3]);
}
}

0 comments on commit fdcf8f8

Please sign in to comment.