limits-util: add assert for physical memory calculation overflow

Coverity flags (uint64_t) sc * (uint64_t) ps as a potential
overflow. Add an assert to make the bounds explicit for static
analyzers.

CID#1548042

Follow-up for eefc66aa8f
This commit is contained in:
Luca Boccassi
2026-03-28 21:14:07 +00:00
parent 02f848b375
commit 09bb6448ae

View File

@@ -28,6 +28,8 @@ uint64_t physical_memory(void) {
assert(sc > 0);
ps = page_size();
/* Silence static analyzers */
assert((uint64_t) sc <= UINT64_MAX / (uint64_t) ps);
mem = (uint64_t) sc * (uint64_t) ps;
r = cg_get_root_path(&root);