diff --git a/src/ChangeLog b/src/ChangeLog index 023febf62..0cc536fa8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2004-09-10 Jakub Jelinek + + * 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 * info.c (info_show_info): don't truncate block counts to 32 bits diff --git a/src/view.c b/src/view.c index 67a161052..5d6a7499c 100644 --- a/src/view.c +++ b/src/view.c @@ -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;