Explorar o código

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 %!s(int64=7) %!d(string=hai) anos
pai
achega
7a4725f9da
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  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;
 	end = start+(strlen(start))-1;
 	while ((*end == ' ' || *end == '\t' || (remove_colon_and_brace && (*end == ':' || *end == '{'))) && end > start)
 	while ((*end == ' ' || *end == '\t' || (remove_colon_and_brace && (*end == ':' || *end == '{'))) && end > start)
 		end--;
 		end--;
-	if (end != start)
-		*(end+1) = '\0';
+	if (*end != '\0')
+		*(end + 1) = '\0';
 
 
 	return start;
 	return start;
 }
 }