< prev index next >

src/share/vm/compiler/directivesParser.cpp

Print this page
rev 13166 : read/write APIs in class os shall return ssize_t

*** 1,7 **** /* ! * Copyright (c) 2015, 2016, 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. --- 1,7 ---- /* ! * Copyright (c) 2015, 2017, 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.
*** 91,103 **** if (os::stat(filename, &st) == 0) { // found file, open it int file_handle = os::open(filename, 0, 0); if (file_handle != -1) { // read contents into resource array ! char* buffer = NEW_RESOURCE_ARRAY(char, st.st_size+1); ! size_t num_read = os::read(file_handle, (char*) buffer, st.st_size); ! buffer[num_read] = '\0'; // close file os::close(file_handle); return parse_string(buffer, stream) > 0; } } --- 91,103 ---- if (os::stat(filename, &st) == 0) { // found file, open it int file_handle = os::open(filename, 0, 0); if (file_handle != -1) { // read contents into resource array ! char* buffer = NEW_RESOURCE_ARRAY(char, st.st_size + 1); ! ssize_t num_read = os::read(file_handle, (char*) buffer, st.st_size); ! buffer[num_read < 0 ? 0 : (size_t)num_read] = '\0'; // close file os::close(file_handle); return parse_string(buffer, stream) > 0; } }
< prev index next >