diff --git a/ChangeLog b/ChangeLog index 7175cae8..e95baa55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -62,6 +62,10 @@ CVS code - do_justify() - For consistency, preserve placewewant if we didn't unjustify instead of setting it to 0. (DLR) + - When justifying the entire file, properly break out of the + loop if there are no more paragraphs after the current one and + the paragraph search left us on the magicline, so as to avoid + a segfault. (DLR) - winio.c: unget_kbinput() - Remove the wide character handling, as it didn't work properly diff --git a/src/nano.c b/src/nano.c index 3408b79b..9cdfc711 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2771,15 +2771,15 @@ void do_justify(bool full_justify) /* Find the first line of the paragraph to be justified. That * is the start of this paragraph if we're in one, or the start * of the next otherwise. Save the quote length and paragraph - * length (number of lines). Don't refresh the screen yet - * (since we'll do that after we justify). If the search failed - * and we're justifying the whole file, move the last line of - * the text we're justifying to just before the magicline, which - * is where it'll be anyway if we've searched the entire file, - * and break out of the loop; otherwise, refresh the screen and + * length (number of lines). Don't refresh the screen yet, + * since we'll do that after we justify. If the search + * failed, we're justifying the whole file, and the search + * didn't leave us on the last line of the file, set the last + * line of the text to be justified to the last line of the file + * and break out of the loop. Otherwise, refresh the screen and * get out. */ if (do_para_search("e_len, &par_len)) { - if (full_justify) { + if (full_justify && current != filebot) { last_par_line = filebot; break; } else {