<p>In <a href="https://github.com/geany/geany-plugins/pull/324#discussion_r49946955">lineoperations/src/linefunctions.c</a>:</p>
<pre style='color:#555'>> +
> + sci_end_undo_action(doc->editor->sci);
> +}
> +
> +
> +/* Sort Lines Ascending and Descending */
> +void sortlines(GeanyDocument *doc, gboolean asc) {
> + gint total_num_chars; /* number of characters in the document */
> + gint total_num_lines; /* number of lines in the document */
> + gchar **lines; /* array to hold all lines in the document */
> + gchar *new_file; /* *final* string to replace current document */
> + gint i; /* iterator */
> +
> + total_num_chars = sci_get_length(doc->editor->sci);
> + total_num_lines = sci_get_line_count(doc->editor->sci);
> + lines = g_malloc(sizeof(gchar *) * total_num_lines+1);
</pre>
<p>there's a subtle bug here: the +1 is not applied correctly as <code>*</code> has priority over <code>+</code>. Wrap in parentheses. (thanks to Valgrind for finding this)</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-plugins/pull/324/files#r49946955">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ8QED4J_4G_MCQxoRifNw3G53B5Rks5pa5yfgaJpZM4HBhj7.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-plugins/pull/324/files#r49946955"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>