backport r13488

svn:r13489
This commit is contained in:
Roger Dingledine 2008-02-13 07:25:27 +00:00
parent c3bd8d144c
commit 27227679b4
2 changed files with 4 additions and 3 deletions

View File

@ -13,6 +13,8 @@ Changes in versino 0.1.2.20 - 2008-??-??
Resolves bug 597.
- Fix a few memory leaks that could in theory happen under bizarre error
conditions.
- We were leaking a file descriptor if Tor started with a zero-length
cached-descriptors file. Patch by freddy77.
Changes in version 0.1.2.19 - 2008-01-17

View File

@ -158,19 +158,18 @@ tor_mmap_file(const char *filename)
/* Zero-length file. If we call mmap on it, it will succeed but
* return NULL, and bad things will happen. So just fail. */
log_info(LD_FS,"File \"%s\" is empty. Ignoring.",filename);
close(fd);
return NULL;
}
string = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
if (string == MAP_FAILED) {
close(fd);
log_warn(LD_FS,"Could not mmap file \"%s\": %s", filename,
strerror(errno));
return NULL;
}
close(fd);
res = tor_malloc_zero(sizeof(tor_mmap_impl_t));
res->base.data = string;
res->base.size = filesize;