<p>The <code>DOC_VALID</code> check needs to be moved up before the 2nd line of the function where <code>doc->editor</code> is dereferenced, like this:</p>
<div class="highlight highlight-source-c"><pre><span class="pl-k">static</span> gboolean
<span class="pl-en">automark</span>(gpointer user_data)
{
        GeanyDocument      *doc = (GeanyDocument *)user_data;

        <span class="pl-c"><span class="pl-c">/*</span> during timeout document could be destroyed so check everything again <span class="pl-c">*/</span></span>
        <span class="pl-k">if</span> (!<span class="pl-c1">DOC_VALID</span>(doc))
                <span class="pl-k">return</span> <span class="pl-c1">FALSE</span>;

        GeanyEditor        *editor = doc-><span class="pl-smi">editor</span>;
        <span class="pl-k">static</span> GeanyEditor *editor_cache = <span class="pl-c1">NULL</span>;
        ScintillaObject    *sci = editor-><span class="pl-smi">sci</span>;
        gchar              *text;
        <span class="pl-k">static</span> gchar        text_cache[GEANY_MAX_WORD_LENGTH] = {<span class="pl-c1">0</span>};
        gint                match_flag = SCFIND_MATCHCASE | SCFIND_WHOLEWORD;
        <span class="pl-k">struct</span>              Sci_TextToFind ttf;

        source_id = <span class="pl-c1">0</span>;

        <span class="pl-c"><span class="pl-c">/*</span> Do not highlight while selecting text and allow other markers to work <span class="pl-c">*/</span></span>
        <span class="pl-k">if</span> (<span class="pl-c1">sci_has_selection</span>(sci))
                <span class="pl-k">return</span> <span class="pl-c1">FALSE</span>;</pre></div>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany-plugins/issues/574?email_source=notifications&email_token=AAIOWJZQ7XMV34C4YE6FAM3PVSVZ7A5CNFSM4DKOP4CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVQK3YA#issuecomment-492875232">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ6UMKI4UPS5FCTHO6DPVSVZ7ANCNFSM4DKOP4CA">mute the thread</a>.<img src="https://github.com/notifications/beacon/AAIOWJ5QIDQS52EL7KQHVA3PVSVZ7A5CNFSM4DKOP4CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVQK3YA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany-plugins/issues/574?email_source=notifications\u0026email_token=AAIOWJZQ7XMV34C4YE6FAM3PVSVZ7A5CNFSM4DKOP4CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVQK3YA#issuecomment-492875232",
"url": "https://github.com/geany/geany-plugins/issues/574?email_source=notifications\u0026email_token=AAIOWJZQ7XMV34C4YE6FAM3PVSVZ7A5CNFSM4DKOP4CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVQK3YA#issuecomment-492875232",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>