<p>In <a href="https://github.com/geany/geany/pull/621#discussion_r40621975">src/document.c</a>:</p>
<pre style='color:#555'>>      {
>            ui_set_statusbar(TRUE, "%s", err->message);
>            g_error_free(err);
>            return FALSE;
>    }
>  
> -  filedata->len = (gsize) st.st_size;
</pre>
<p><a href="https://github.com/techee" class="user-mention">@techee</a>, the <code>stat</code> is done here (well just above) so we have the size, so unless something else does another <code>stat</code> it needs to be passed to <code>handle_buffer()</code> to compare to the <code>strlen()</code>.</p>

<p><code>encodings_convert_to_utf8_auto()</code> therefore expects the buffer length here and passes back the modified length after converting the encoding.</p>

<p>For that purpose it doesn't matter if you use the <code>stat</code> value or the <code>*_contents()</code> value, since if they are different there has been a read error.</p>

<p>So I would just use the buffer size returned by Glib/GIO since it is a more direct measure of the buffer size.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/geany/geany/pull/621/files#r40621975">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ8ZY1juH6SZ7YNW2DHGfYKvju15Qks5o2c-2gaJpZM4FwLm6.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/621/files#r40621975"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>