Skip to content

Commit

Permalink
macros: Add a size check for hashtable iters
Browse files Browse the repository at this point in the history
If the user provides a less than pointer-sized type, we'll clobber other things
on the stack.

See ostreedev/ostree#990
  • Loading branch information
cgwalters committed Jun 30, 2017
1 parent 01e934c commit a37e672
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions glnx-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ G_BEGIN_DECLS

#define _GLNX_HASH_TABLE_FOREACH_IMPL_KV(guard, ht, it, kt, k, vt, v) \
gboolean guard = TRUE; \
G_STATIC_ASSERT (sizeof (kt) == sizeof (void*)); \
G_STATIC_ASSERT (sizeof (vt) == sizeof (void*)); \
for (GHashTableIter it; \
guard && ({ g_hash_table_iter_init (&it, ht), TRUE; }); \
guard = FALSE) \
Expand Down

0 comments on commit a37e672

Please sign in to comment.