From 09b812485917a0ab6810bf0d6e6889c81c4edcfb Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Sat, 12 Jul 2008 01:54:49 +0000 Subject: [PATCH] Savannah bug 23751: Segfault when viewing help using Japanese locale Fix break_line crashing when using certain locales from Mitsuya Shibata git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4272 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/text.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index fc99dd23..bae4cd4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2008-07-11 Mitsuya Shibata + * text.c: Fix crashing in help menu when using certain locales + 2008-07-09 Chris Allegretta * nano.c/nano.h/global.c/text.c: New generalized undo code, currently just works for adding and deleting text and splitting and unsplitting lines. diff --git a/src/text.c b/src/text.c index bdf82a1b..0ccfebc3 100644 --- a/src/text.c +++ b/src/text.c @@ -1127,6 +1127,15 @@ ssize_t break_line(const char *line, ssize_t goal /* In fact, the whole line displays shorter than goal. */ return cur_loc; +#ifndef DISABLE_HELP + if (newln && blank_loc <= 0) { + /* If blank was not found or was found only first character, + * force line break. */ + cur_loc -= line_len; + return cur_loc; + } +#endif + if (blank_loc == -1) { /* No blank was found that was short enough. */ bool found_blank = FALSE; -- 2.39.5