On 01/27/22 17:39, Richard W.M. Jones wrote:
I'm not certain if it is wrong to ever call munlock(2) with the
first
parameter NULL (second parameter 0). Linux permits it. POSIX doesn't
say either way. In any case it's not necessary to do it, so add an
extra check to avoid it here.
---
common/allocators/malloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/allocators/malloc.c b/common/allocators/malloc.c
index eea44432..9a2dd549 100644
--- a/common/allocators/malloc.c
+++ b/common/allocators/malloc.c
@@ -96,7 +96,7 @@ extend (struct m_alloc *ma, uint64_t new_size)
/* Since the memory might be moved by realloc, we must unlock the
* original array.
*/
- if (ma->use_mlock)
+ if (ma->use_mlock && ma->ba.ptr != NULL)
munlock (ma->ba.ptr, ma->ba.cap);
#endif
Reviewed-by: Laszlo Ersek <lersek(a)redhat.com>