aboutsummaryrefslogtreecommitdiffstats
path: root/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ui.c b/ui.c
index 979cb00..194f20d 100644
--- a/ui.c
+++ b/ui.c
@@ -84,12 +84,16 @@ const char *curtail(const char *str, const char *sep, int len)
const char fallback_sep[] = "~";
int l = 0, front, mid, back;
- assert(len < sizeof(out_buf));
+ if (len >= sizeof(out_buf))
+ len = sizeof(out_buf) - 1;
- if (sep == NULL)
+ if (sep == NULL || *sep == '\0')
sep = fallback_sep;
mid = strlen(sep);
- assert(len >= mid);
+ if (mid > len) {
+ sep = fallback_sep;
+ mid = strlen(sep);
+ }
if (str != NULL)
l = strlen(str);