(ef_open): Zero cache size (empty EFF_MEM file) can lead to null cache
on some systems, which confuses assertions. Force non-zero size.
This commit is contained in:
parent
99afa2adce
commit
211a56489b
1 changed files with 5 additions and 2 deletions
|
@ -114,12 +114,15 @@ ef_open(int type, int how)
|
||||||
if (how & EFF_MEM)
|
if (how & EFF_MEM)
|
||||||
ep->csize = ep->fids;
|
ep->csize = ep->fids;
|
||||||
else
|
else
|
||||||
ep->csize = MAX(1, blksize(fd) / ep->size);
|
ep->csize = blksize(fd) / ep->size;
|
||||||
|
/* 0 could lead to null cache, which confuses assertions */
|
||||||
|
if (!ep->csize)
|
||||||
|
ep->csize++;
|
||||||
size = ep->csize * ep->size;
|
size = ep->csize * ep->size;
|
||||||
if (CANT_HAPPEN(ep->cache))
|
if (CANT_HAPPEN(ep->cache))
|
||||||
free(ep->cache);
|
free(ep->cache);
|
||||||
ep->cache = malloc(size);
|
ep->cache = malloc(size);
|
||||||
if (ep->cache == NULL && size) {
|
if (ep->cache == NULL) {
|
||||||
logerror("Can't open %s: out of memory", ep->file);
|
logerror("Can't open %s: out of memory", ep->file);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue