1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

macro: check over flow in reference counter

This commit is contained in:
Yu Watanabe 2022-04-17 06:54:50 +09:00
parent 6dd18b34cf
commit c8431e9e35

View File

@ -396,8 +396,12 @@ static inline int __coverity_check_and_return__(int condition) {
if (!p) \
return NULL; \
\
assert(p->n_ref > 0); \
p->n_ref++; \
/* For type check. */ \
unsigned *q = &p->n_ref; \
assert(*q > 0); \
assert(*q < UINT_MAX); \
\
(*q)++; \
return p; \
}