diff options
| author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-06-04 20:58:46 +0100 |
|---|---|---|
| committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-06-04 20:58:46 +0100 |
| commit | 53c578ab41a18686c99b7168dc6e7de4479fb74f (patch) | |
| tree | 459d94ff81842bd887d34334c9a62c85d1af9afa /src/input | |
| parent | 4bc3f24d3a85f682707851e6865a2c890c326c2c (diff) | |
| parent | f022bad42861429cac5c56c575b54819ba092b98 (diff) | |
| download | xine-lib-53c578ab41a18686c99b7168dc6e7de4479fb74f.tar.gz xine-lib-53c578ab41a18686c99b7168dc6e7de4479fb74f.tar.bz2 | |
Merge from 1.1.
Diffstat (limited to 'src/input')
| -rw-r--r-- | src/input/input_file.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/input/input_file.c b/src/input/input_file.c index 0ec25e1f8..1dce8baad 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -359,6 +359,9 @@ static int file_plugin_open (input_plugin_t *this_gen ) { file_input_plugin_t *this = (file_input_plugin_t *) this_gen; char *filename; struct stat sbuf; +#ifdef HAVE_MMAP + size_t tmp_size; +#endif lprintf("file_plugin_open\n"); @@ -423,10 +426,14 @@ static int file_plugin_open (input_plugin_t *this_gen ) { } #ifdef HAVE_MMAP - if ( (this->mmap_base = mmap(NULL, sbuf.st_size, PROT_READ, MAP_SHARED, this->fh, 0)) != (void*)-1 ) { + tmp_size = sbuf.st_size; /* may cause truncation - if it does, DON'T mmap! */ + if ((tmp_size == sbuf.st_size) && + ( (this->mmap_base = mmap(NULL, tmp_size, PROT_READ, MAP_SHARED, this->fh, 0)) != (void*)-1 )) { this->mmap_on = 1; this->mmap_curr = this->mmap_base; this->mmap_len = sbuf.st_size; + } else { + this->mmap_base = NULL; } #endif |
