* view.c (get_byte): Fix avoid dying if file is too large

to fit into memory.
        (load_view_file): Fix avoid mmaping just part of a >=4GB file
        on 32-bit arches.
This commit is contained in:
Andrew V. Samoilov 2004-09-10 09:14:55 +00:00
parent 221bb320b8
commit b6ad379291
2 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2004-09-10 Jakub Jelinek <jakub@redhat.com>
* view.c (get_byte): Fix avoid dying if file is too large
to fit into memory.
(load_view_file): Fix avoid mmaping just part of a >=4GB file
on 32-bit arches.
2004-09-04 Jakub Jelinek <jakub@redhat.com>
* info.c (info_show_info): don't truncate block counts to 32 bits

View File

@ -281,7 +281,7 @@ get_byte (WView *view, unsigned int byte_index)
view->block_ptr = g_realloc (view->block_ptr,
page * sizeof (char *));
for (i = view->blocks; i < page; i++) {
char *p = g_malloc (VIEW_PAGE_SIZE);
char *p = g_try_malloc (VIEW_PAGE_SIZE);
view->block_ptr[i] = p;
if (!p)
return '\n';
@ -545,9 +545,11 @@ load_view_file (WView *view, int fd)
return init_growing_view (view, 0, view->filename);
}
#ifdef HAVE_MMAP
view->data =
mc_mmap (0, view->s.st_size, PROT_READ, MAP_FILE | MAP_SHARED,
view->file, 0);
if ((size_t) view->s.st_size == view->s.st_size)
view->data = mc_mmap (0, view->s.st_size, PROT_READ,
MAP_FILE | MAP_SHARED, view->file, 0);
else
view->data = (caddr_t) -1;
if ((caddr_t) view->data != (caddr_t) - 1) {
/* mmap worked */
view->first = 0;