mem: handle potential error from sysconf(_SC_PAGESIZE)
Reported by Coverity scan. * mem.c (get_pagesize): Handle the case when sysconf(_SC_PAGESIZE) returns an error.
This commit is contained in:
parent
e1499151e9
commit
4eb79a767d
14
mem.c
14
mem.c
@ -40,8 +40,18 @@ get_pagesize(void)
|
||||
{
|
||||
static unsigned long pagesize;
|
||||
|
||||
if (!pagesize)
|
||||
pagesize = sysconf(_SC_PAGESIZE);
|
||||
if (!pagesize) {
|
||||
long ret = sysconf(_SC_PAGESIZE);
|
||||
|
||||
if (ret < 0)
|
||||
perror_func_msg_and_die("sysconf(_SC_PAGESIZE)");
|
||||
if (ret == 0)
|
||||
error_func_msg_and_die("sysconf(_SC_PAGESIZE) "
|
||||
"returned 0");
|
||||
|
||||
pagesize = (unsigned long) ret;
|
||||
}
|
||||
|
||||
return pagesize;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user