commit c0e3779453e43269317470e00f48f00e60357a77
parent bf6bcde0788fa8dd9c1d7365b011a833c247ca91
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 12 Apr 2019 19:15:48 +0200
display: report and catch a bad state, to prevent a possible hang
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -1888,6 +1888,13 @@ char *display_string(const char *buf, size_t column, size_t span,
/* Allocate enough space for converting the relevant part of the line. */
converted = charalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
+#ifndef NANO_TINY
+ if (span > HIGHEST_POSITIVE) {
+ statusline(ALERT, "Span has underflowed -- please report a bug");
+ converted[0] = '\0';
+ return converted;
+ }
+#endif
/* If the first character starts before the left edge, or would be
* overwritten by a "<" token, then show placeholders instead. */
if (*buf != '\0' && *buf != '\t' && (start_col < column ||