From f38a095aa0cc721c40050cb074116c153608a11b Mon Sep 17 00:00:00 2001 From: tihmstar Date: Thu, 14 Dec 2023 05:16:34 +0000 Subject: [PATCH] fix undefined behavior (which resulted in running out of memory) (#34) --- ldid.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ldid.cpp b/ldid.cpp index c93a66a..237b1c7 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -555,6 +555,7 @@ static const uint8_t PageShift_(0x0c); static const uint32_t PageSize_(1 << PageShift_); static inline unsigned bytes(uint64_t value) { + if (!value) return 1; return (64 - __builtin_clzll(value) + 7) / 8; }