< prev index next >
src/share/vm/memory/filemap.cpp
Print this page
rev 13166 : read/write APIs in class os shall return ssize_t
@@ -358,12 +358,12 @@
// Read the FileMapInfo information from the file.
bool FileMapInfo::init_from_file(int fd) {
size_t sz = _header->data_size();
char* addr = _header->data();
- size_t n = os::read(fd, addr, (unsigned int)sz);
- if (n != sz) {
+ ssize_t n = os::read(fd, addr, (unsigned int)sz);
+ if (n < 0 || (size_t)n != sz) {
fail_continue("Unable to read the file header.");
return false;
}
if (_header->_version != current_version()) {
fail_continue("The shared archive file has the wrong version.");
@@ -376,11 +376,11 @@
if (_paths_misc_info == NULL) {
fail_continue("Unable to read the file header.");
return false;
}
n = os::read(fd, _paths_misc_info, (unsigned int)info_size);
- if (n != info_size) {
+ if (n < 0 || (size_t)n != info_size) {
fail_continue("Unable to read the shared path info header.");
FREE_C_HEAP_ARRAY(char, _paths_misc_info);
_paths_misc_info = NULL;
return false;
}
< prev index next >