diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-10-18 14:19:00 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-18 14:19:00 +0900 |
commit | 8dc1d0bf64ce84030a1a13ea64343f816dba9e27 (patch) | |
tree | e499e53c0c014a181edf769a519e43b9c9af9c22 | |
parent | 181f145de337418e22712d03bd394209cb68d12f (diff) | |
parent | ac7da78ede468315ba22d9ee1265b61a744371ee (diff) | |
download | git-8dc1d0bf64ce84030a1a13ea64343f816dba9e27.tar.gz git-8dc1d0bf64ce84030a1a13ea64343f816dba9e27.tar.xz |
Merge branch 'mh/for-each-string-list-item-empty-fix' into maint
Code cmp.std.c nitpick.
* mh/for-each-string-list-item-empty-fix:
for_each_string_list_item: avoid undefined behavior for empty list
-rw-r--r-- | string-list.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/string-list.h b/string-list.h index 29bfb7ae4..79ae567cb 100644 --- a/string-list.h +++ b/string-list.h @@ -32,8 +32,10 @@ void string_list_clear_func(struct string_list *list, string_list_clear_func_t c typedef int (*string_list_each_func_t)(struct string_list_item *, void *); int for_each_string_list(struct string_list *list, string_list_each_func_t, void *cb_data); -#define for_each_string_list_item(item,list) \ - for (item = (list)->items; item < (list)->items + (list)->nr; ++item) +#define for_each_string_list_item(item,list) \ + for (item = (list)->items; \ + item && item < (list)->items + (list)->nr; \ + ++item) /* * Apply want to each item in list, retaining only the ones for which |