< prev index next >
test/hotspot/gtest/logging/logTestUtils.inline.hpp
Print this page
rev 50985 : 8206977: Minor improvements of runtime code.
Reviewed-by: coleenp, lfoltan
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -93,10 +93,11 @@
static inline char* read_line(FILE* fp) {
assert(fp != NULL, "invalid fp");
int buflen = 512;
char* buf = NEW_RESOURCE_ARRAY(char, buflen);
long pos = ftell(fp);
+ if (pos < 0) return NULL;
char* ret = fgets(buf, buflen, fp);
while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) {
// retry with a larger buffer
buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2);
< prev index next >