Skip to content

Commit f6a17a2

Browse files
author
H. Peter Anvin
committed
nasmlib.h: protect list_last() macro against misuse
The list_last() macro is a statement macro; wrap it in a do { ... } while(0) block to prevent accidental misuse. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
1 parent f744ec4 commit f6a17a2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

include/nasmlib.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,11 @@ const char *filename_set_extension(const char *inname, const char *extension);
367367
#define list_for_each_safe(pos, _n, head) \
368368
for (pos = head, _n = (pos ? pos->next : NULL); pos; \
369369
pos = _n, _n = (_n ? _n->next : NULL))
370-
#define list_last(pos, head) \
371-
for (pos = head; pos && pos->next; pos = pos->next) \
372-
;
370+
#define list_last(pos, head) \
371+
do { \
372+
for (pos = head; pos && pos->next; pos = pos->next) \
373+
; \
374+
} while (0)
373375
#define list_reverse(head) \
374376
do { \
375377
void *_p, *_n; \

0 commit comments

Comments
 (0)