mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
array: check that we are still in the tab
If the array is modified while we are running the foreach() loop, the tab of the array may be reallocated, so var can be totally out of the memory: check for that. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
1cbb1c0666
commit
56225a39fe
1 changed files with 2 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* array.h - useful array handling header
|
||||
*
|
||||
* Copyright © 2009 Julien Danjou <julien@danjou.info>
|
||||
* Copyright © 2008 Pierre Habouzit <madcoder@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -32,7 +33,7 @@
|
|||
|
||||
#define foreach(var, array) \
|
||||
for(typeof((array).tab) var = (array).tab; \
|
||||
var < (array).tab + (array).len; \
|
||||
var >= (array).tab && var < (array).tab + (array).len; \
|
||||
var++)
|
||||
|
||||
#define ARRAY_FUNCS(type_t, pfx, dtor) \
|
||||
|
|
Loading…
Reference in a new issue