projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6dd18b3
)
macro: check over flow in reference counter
author
Yu Watanabe
<watanabe.yu+github@gmail.com>
Sat, 16 Apr 2022 21:54:50 +0000
(06:54 +0900)
committer
Yu Watanabe
<watanabe.yu+github@gmail.com>
Tue, 19 Apr 2022 08:58:02 +0000
(17:58 +0900)
src/basic/macro.h
patch
|
blob
|
history
diff --git
a/src/basic/macro.h
b/src/basic/macro.h
index 68d8b062e87330983304a1ed875014d37d65ea00..6e3966ff486687784dbda4d074145c03e7790a24 100644
(file)
--- a/
src/basic/macro.h
+++ b/
src/basic/macro.h
@@
-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; \
}