Skip to content

Commit

Permalink
Merge pull request #391 from b4n/lineoperations/leak
Browse files Browse the repository at this point in the history
lineoperations: Fix a memory leak found by cppcheck
  • Loading branch information
frlan committed Mar 8, 2016
2 parents 9491cc1 + fb53d8c commit 42afeae
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lineoperations/src/linefunctions.c
Expand Up @@ -286,17 +286,13 @@ void rmwhspln(GeanyDocument *doc) {

/* 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));
new_file = g_malloc(sizeof(gchar) * (total_num_chars+1));
new_file[0] = '\0';

/* if file is not empty, ensure that the file ends with newline */
if(total_num_lines != 1)
Expand Down

0 comments on commit 42afeae

Please sign in to comment.