safeguard errno
diff --git a/rpmalloc/rpmalloc.c b/rpmalloc/rpmalloc.c
index 5cb8f78..5186f61 100644
--- a/rpmalloc/rpmalloc.c
+++ b/rpmalloc/rpmalloc.c
@@ -925,8 +925,9 @@
} else {
#if defined(MADV_FREE_REUSABLE)
int ret;
- while ((ret = madvise(address, size, MADV_FREE_REUSABLE)) == -1 && errno == EAGAIN);
- if (ret == -1 && errno != 0)
+ while ((ret = madvise(address, size, MADV_FREE_REUSABLE)) == -1 && (errno == EAGAIN))
+ errno = 0;
+ if ((ret == -1) && (errno != 0))
#elif defined(MADV_FREE)
if (madvise(address, size, MADV_FREE))
#endif