Skip to content

Commit cad2ec7

Browse files
committed
Fix out of bound in rtrim()
When the string with length zero, it might be coredump because of out-of-bound in rtrim(). Reported-By: CPUBarbecue
1 parent b958738 commit cad2ec7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pg_node2graph.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ rtrim(const string& str)
364364
{
365365
size_t len = str.size();
366366

367-
while (isspace(str[len - 1])) {
367+
while (len > 0 && isspace(str[len - 1])) {
368368
len--;
369369
}
370370

0 commit comments

Comments
 (0)