From d54f1e4329aa2b80107383f99253f5f3df9f1f84 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 26 Jul 2025 02:23:52 +0900 Subject: [PATCH] cpu-set-util: check if cpu set is already allocated Prompted by CID#1611789, CID#1611790, and CID#1611791. --- src/shared/cpu-set-util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c index cef23889ca..222e4b7e17 100644 --- a/src/shared/cpu-set-util.c +++ b/src/shared/cpu-set-util.c @@ -133,8 +133,10 @@ int cpu_set_realloc(CPUSet *c, size_t n) { return -ERANGE; n = CPU_ALLOC_SIZE(n); - if (n <= c->allocated) + if (n <= c->allocated) { + assert(c->set || n == 0); return 0; + } if (!GREEDY_REALLOC0(c->set, DIV_ROUND_UP(n, sizeof(cpu_set_t)))) return -ENOMEM;