mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Add a null statement to prevent some SMARTLIST_FOREACH() bugs.
So we require that SMARTLIST_FOREACH_END() have the name of the loop variable in it. But right now the only enforcement for that is to clear the variable at the end of the loop, which is really not sufficient: I spent 45 minutes earlier today debugging an issue where I had said: SMARTLIST_FOREACH_BEGIN(spool, spooled_resource_t *, spooled) { ... } SMARTLIST_FOREACH_END(spool); This patch makes it so that ONLY loop variables can be used, by referring to the _sl_idx variable.
This commit is contained in:
parent
d9cd4b7072
commit
dc37ea8b98
@ -224,6 +224,7 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
|
||||
|
||||
#define SMARTLIST_FOREACH_END(var) \
|
||||
var = NULL; \
|
||||
(void) var ## _sl_idx; \
|
||||
} STMT_END
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user