diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2022-06-17 23:32:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-17 23:32:19 +0300 |
commit | 66501252514b36a18788fb1a0987f46a19fa4cb7 (patch) | |
tree | e0316e99832052846d6405b27530f329c5a33fb1 /libnetdata | |
parent | bb73237748a59290cd92e678978db41f09a11635 (diff) |
Fix coverity 378587 (#13024)
* check for return value of sysconf
* if sysconf fails set OWA_NATURAL_PAGE_SIZE to 4096
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/onewayalloc/onewayalloc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libnetdata/onewayalloc/onewayalloc.c b/libnetdata/onewayalloc/onewayalloc.c index 267e386341..6023eff983 100644 --- a/libnetdata/onewayalloc/onewayalloc.c +++ b/libnetdata/onewayalloc/onewayalloc.c @@ -30,8 +30,13 @@ static inline size_t natural_alignment(size_t size) { // any number of times, for any amount of memory. static OWA_PAGE *onewayalloc_create_internal(OWA_PAGE *head, size_t size_hint) { - if(unlikely(!OWA_NATURAL_PAGE_SIZE)) - OWA_NATURAL_PAGE_SIZE = sysconf(_SC_PAGE_SIZE); + if(unlikely(!OWA_NATURAL_PAGE_SIZE)) { + long int page_size = sysconf(_SC_PAGE_SIZE); + if (unlikely(page_size == -1)) + OWA_NATURAL_PAGE_SIZE = 4096; + else + OWA_NATURAL_PAGE_SIZE = page_size; + } // our default page size size_t size = OWA_NATURAL_PAGE_SIZE; |