Skip to content

Commit

Permalink
8261949: fileStream::readln returns incorrect line string
Browse files Browse the repository at this point in the history
Reviewed-by: dcubed, dholmes
  • Loading branch information
y1yang0 authored and DamonFool committed Feb 22, 2021
1 parent 539c80b commit 2b55501
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hotspot/share/utilities/ostream.cpp
Expand Up @@ -589,8 +589,11 @@ char* fileStream::readln(char *data, int count ) {
char * ret = NULL;
if (_file != NULL) {
ret = ::fgets(data, count, _file);
//Get rid of annoying \n char
data[::strlen(data)-1] = '\0';
// Get rid of annoying \n char only if it is present.
size_t len = ::strlen(data);
if (len > 0 && data[len - 1] == '\n') {
data[len - 1] = '\0';
}
}
return ret;
}
Expand Down

1 comment on commit 2b55501

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.