aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorDan Carpenter <dan.carpenter@oracle.com>2015-07-23 11:24:14 +0300
committerChristopher Li <sparse@chrisli.org>2015-08-04 13:23:46 -0400
commit0d2809b500cd831851d1ac734419165949b0f0ab (patch)
tree42b02ecf5a7e9ec24b3b66bc99099c9a22a6b022
parenta53cea28f0db1c799668476ec7612cf120cddcc0 (diff)
downloadsparse-dev-0d2809b500cd831851d1ac734419165949b0f0ab.tar.gz
ptrlist: reading deleted items in NEXT_PTR_LIST()
If you call DELETE_CURRENT_PTR(), then you can sometimes end up with a __list->nr that is zero. The FOR_EACH_PTR() macro can handle this but the NEXT_PTR_LIST() macro returns ptr = 0xf0f0f0f0 which leads to a segfault. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r--ptrlist.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/ptrlist.h b/ptrlist.h
index 58d3bdaa..61e159fd 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -97,6 +97,8 @@ static inline void *last_ptr_list(struct ptr_list *list)
} else { \
__list = __list->next; \
ptr = NULL; \
+ while (__list->nr == 0 && __list != __head) \
+ __list = __list->next; \
if (__list != __head) { \
__nr = 0; \
ptr = PTR_ENTRY(__list,0); \