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
This commit is contained in:
Alfonso S. Siciliano 2022-06-06 21:07:03 +02:00
parent ad52a7bb03
commit 559de8eedb
No known key found for this signature in database
GPG Key ID: 3F9EEFACFD371E37

View File

@ -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;
}
}