commit ad1b64cdfa2b96175c2c3bf93dee0db9a39a1e51
parent 79383beef3dc3dec3a343dd94eb54b4ad8211c58
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 29 Nov 2005 19:00:09 +0000
in do_justify(), renumber after justifying each individual paragraph,
since find_paragraph() needs the line numbers to be right as well as
edit_refresh(); this fixes a potential segfault when doing full justify
with auto-indent turned on
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3226 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -211,6 +211,10 @@ CVS code -
as the reset_cursor() called by edit_refresh() after restoring
edittop and current will ensure that current_y is restored to
its original value. (DLR)
+ - Renumber after justifying each individual paragraph, since
+ find_paragraph() needs the line numbers to be right as well as
+ edit_refresh(). This fixes a potential segfault when doing
+ full justify with auto-indent turned on. (DLR)
do_alt_speller()
- Move the code that replaces the text of the current file with
the text of the spell-checked file into its own function,
diff --git a/src/text.c b/src/text.c
@@ -1448,22 +1448,25 @@ void do_justify(bool full_justify)
} else
openfile->current_x = strlen(openfile->current->data);
- /* We've just justified a paragraph. If we're not justifying the
- * entire file, break out of the loop. Otherwise, continue the
- * loop so that we justify all the paragraphs in the file. */
+ /* Renumber the lines of the now-justified paragraph, since both
+ * find_paragraph() and edit_refresh() need the line numbers to
+ * be right. */
+ renumber(first_par_line);
+
+ /* We've just finished justifying the paragraph. If we're not
+ * justifying the entire file, break out of the loop.
+ * Otherwise, continue the loop so that we justify all the
+ * paragraphs in the file. */
if (!full_justify)
break;
}
/* We are now done justifying the paragraph or the file, so clean
* up. current_y and totsize have been maintained above. If we
- * actually justified something, renumber, since edit_refresh()
- * needs the line numbers to be right, and set last_par_line to the
- * new end of the paragraph. */
- if (first_par_line != NULL) {
- renumber(first_par_line);
+ * actually justified something, set last_par_line to the new end of
+ * the paragraph. */
+ if (first_par_line != NULL)
last_par_line = openfile->current;
- }
edit_refresh();