Skip to content

Commit

Permalink
lineoperations: Fix underallocation in sortlines()
Browse files Browse the repository at this point in the history
An overlooked operator priority lead to underallocating
`sizeof(gchar*)-1` bytes, later leading to an invalid memory access.
  • Loading branch information
b4n committed Jan 17, 2016
1 parent f05a05b commit ee35465
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lineoperations/src/linefunctions.c
Expand Up @@ -295,7 +295,7 @@ void sortlines(GeanyDocument *doc, gboolean asc) {

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

Expand Down

0 comments on commit ee35465

Please sign in to comment.