git: 559de8eedbc5 - main - bsddialog(3): Fix text wrapping
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Jun 2022 19:12:49 UTC
The branch main has been updated by asiciliano: URL: https://cgit.FreeBSD.org/src/commit/?id=559de8eedbc5cc18982bb254527ed7fe2f8655b2 commit 559de8eedbc5cc18982bb254527ed7fe2f8655b2 Author: Alfonso S. Siciliano <asiciliano@FreeBSD.org> AuthorDate: 2022-06-06 19:07:03 +0000 Commit: Alfonso S. Siciliano <asiciliano@FreeBSD.org> CommitDate: 2022-06-06 19:12:36 +0000 bsddialog(3): Fix text wrapping Fix text wrapping with more than 1024 words. Reported by: brd Reviewed by: bapt, brd Differential Revision: https://reviews.freebsd.org/D35413 --- contrib/bsddialog/lib/lib_util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/bsddialog/lib/lib_util.c b/contrib/bsddialog/lib/lib_util.c index 643830efd58c..506003b52c8d 100644 --- a/contrib/bsddialog/lib/lib_util.c +++ b/contrib/bsddialog/lib/lib_util.c @@ -443,9 +443,10 @@ text_autosize(struct bsddialog_conf *conf, const char *text, int maxrows, continue; } - if (nword + tablen >= maxwords) { + if (nword + tablen + 1 >= maxwords) { maxwords += 1024; - if (realloc(words, maxwords * sizeof(int)) == NULL) + words = realloc(words, maxwords * sizeof(int)); + if (words == NULL) RETURN_ERROR("Cannot realloc memory for text " "autosize"); } @@ -968,4 +969,4 @@ end_dialog(struct bsddialog_conf *conf, WINDOW *shadow, WINDOW *widget, *conf->get_height = h; if (conf->get_width != NULL) *conf->get_width = w; -} \ No newline at end of file +}