소스 검색

coroparse: Fix remove_whitespace end condition

When remove_whitespace function parameter is single character string
with whitespaces (like a:) then colon is not removed. Reason is end
condition end != start, which is valid for empty string, but invalid in
case described above. Solution is to check if *end is '\0'.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 7 년 전
부모
커밋
7a4725f9da
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      exec/coroparse.c

+ 2 - 2
exec/coroparse.c

@@ -275,8 +275,8 @@ static char *remove_whitespace(char *string, int remove_colon_and_brace)
 	end = start+(strlen(start))-1;
 	while ((*end == ' ' || *end == '\t' || (remove_colon_and_brace && (*end == ':' || *end == '{'))) && end > start)
 		end--;
-	if (end != start)
-		*(end+1) = '\0';
+	if (*end != '\0')
+		*(end + 1) = '\0';
 
 	return start;
 }