From f3410da7f0bd208a5f2d792131b215454e782e93 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Sun, 5 Feb 2012 19:04:33 +0000 Subject: Imported Upstream version 0.7.3 --- ui.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ui.c') 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); -- cgit v1.2.3