From 2349e182d22857425d55b5e7ca5da24ab7a3b4df Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Sat, 7 Mar 2015 23:45:07 +0900 Subject: [PATCH] Prevent trim() from segfaulting on an empty string --- config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.c b/config.c index 9e2b67ea..7c2d0014 100644 --- a/config.c +++ b/config.c @@ -185,6 +185,10 @@ trim(char *s) char *s1 = s, *s2 = &s[strlen(s) - 1]; + /* If string is empty, no action needed */ + if(s2 < s1) + return s; + /* Trim and delimit right side */ while ((isspace(*s2)) && (s2 >= s1)) --s2;