]> granicus.if.org Git - libass/commitdiff
Fix trimming function
authorGrigori Goronzy <greg@chown.ath.cx>
Mon, 15 Aug 2011 22:26:16 +0000 (00:26 +0200)
committerGrigori Goronzy <greg@chown.ath.cx>
Fri, 10 Jul 2015 08:42:40 +0000 (10:42 +0200)
Did not correctly handle empty strings (only whitespace). Whoops.

libass/ass_utils.c

index 0fc8b2a5865fe87bd03637ab7834cf8329612bb3..40e6533893509c62a2bc5dc34f2b2bc972620e67 100644 (file)
@@ -338,7 +338,7 @@ char *trim_space(char *str)
     int right = strlen(str) - 1;
 
     while (isspace(str[left])) left++;
-    while (isspace(str[right])) right--;
+    while (right > left && isspace(str[right])) right--;
 
     if (left > 0)
         for (i = 0; i <= right - left; i++)