<p></p>
<p dir="auto">After the update to Scintilla 5.1.5, I started getting memory corruption crashes when saving some files. (Sorry for not noticing this before, I thought the Scintilla update didn't contain any changes on the Geany side.) I may be wrong but I think the problem is in</p>
<p dir="auto"><a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/geany/geany/commit/d7c985e47412f8a53c5a8202a0f8b669c4fd5e08/hovercard" href="https://github.com/geany/geany/commit/d7c985e47412f8a53c5a8202a0f8b669c4fd5e08"><tt>d7c985e</tt></a></p>
<p dir="auto">and misunderstanding if the following Scintilla API change</p>
<blockquote>
<p dir="auto">When calling SCI_GETTEXT, SCI_GETSELTEXT, and SCI_GETCURLINE with a NULL buffer argument to discover the length that should be allocated, do not include the terminating NUL in the returned value. The value returned is 1 less than previous versions of Scintilla. Applications should allocate a buffer 1 more than this to accommodate the NUL. The wParam (length) argument to SCI_GETTEXT and SCI_GETCURLINE also omits the NUL. This is more consistent with other APIs.</p>
</blockquote>
<p dir="auto">This part</p>
<blockquote>
<p dir="auto">When calling SCI_GETTEXT, SCI_GETSELTEXT, and SCI_GETCURLINE with a NULL buffer argument to discover the length that should be allocated, do not include the terminating NUL in the returned value...</p>
</blockquote>
<blockquote>
<p dir="auto">...The wParam (length) argument to SCI_GETTEXT and SCI_GETCURLINE also omits the NUL.</p>
</blockquote>
<p dir="auto">says that that the returned <strong>length</strong> doesn't include NUL, not that the returned string misses the NUL character. The rest of the change description says that we should allocate <code>+1</code> buffer to accommodate for that.</p>
<p dir="auto">I believe we should revert the above patch and then go through all the uses of <code>SCI_GETTEXT</code>, <code>SCI_GETSELTEXT</code>, and <code>SCI_GETCURLINE</code> and corresponding <code>sci_</code> wrappers and update the code where needed (including plugins). I don't think it's a good idea to update the <code>sci_</code> wrappers alone to mirror previous behavior since the whole Scintilla API is part of Geany's API so this is a API change anyway and making <code>sci_</code> functions do something else than direct Scintilla calls is confusing.</p>
<p dir="auto">Rant: I really don't understand why Neil made this change - even though it fixes some inconsistency in Scintilla API, this is a hard to spot backwards incompatible change and such things shouldn't be made in minor releases of a library.</p>
<p dir="auto"><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/kugel-/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/kugel-">@kugel-</a> <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/eht16/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/eht16">@eht16</a> <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/elextr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/elextr">@elextr</a> What do you think?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/3095">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ2MTXXPNOGJLUUHFWTUVP5CTANCNFSM5LV3I2KA">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAIOWJY32YBYKQB4PA7PYNTUVP5CTA5CNFSM5LV3I2KKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4QMALP6A.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><geany/geany/issues/3095</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/issues/3095",
"url": "https://github.com/geany/geany/issues/3095",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>