diff options
| author | Gregor Best <gbe@unobtanium.de> | 2014-09-16 13:24:37 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-16 20:11:57 +0200 |
| commit | 2e61b4456dd3f40097cf6157d7ca53334f802637 (patch) | |
| tree | 4217e96d7bdce0d6c92a44c5488320cde38b4540 | |
| parent | 03efb93095237310273cbe31674cdf115be53544 (diff) | |
| download | vis-2e61b4456dd3f40097cf6157d7ca53334f802637.tar.gz vis-2e61b4456dd3f40097cf6157d7ca53334f802637.tar.xz | |
Fix editing of files with length 0
Signed-off-by: Gregor Best <gbe@unobtanium.de>
| -rw-r--r-- | text.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -663,9 +663,11 @@ Text *text_load(const char *filename) { goto out; // XXX: use lseek(fd, 0, SEEK_END); instead? txt->buf.size = txt->info.st_size; - txt->buf.data = mmap(NULL, txt->info.st_size, PROT_READ, MAP_SHARED, txt->fd, 0); - if (txt->buf.data == MAP_FAILED) - goto out; + if (txt->buf.size != 0) { + txt->buf.data = mmap(NULL, txt->info.st_size, PROT_READ, MAP_SHARED, txt->fd, 0); + if (txt->buf.data == MAP_FAILED) + goto out; + } Piece *p = piece_alloc(txt); if (!p) |
