From c6b0f77923a056bf424047e604ee6f61629eb983 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 10a9e8fe..a69bf854 100644 --- a/config.c +++ b/config.c @@ -260,6 +260,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;