Fix EINA_ARRAY_ITER_NEXT off by one bug. With this fix you can no longer push

NULL pointer inside an array.


SVN revision: 38232
This commit is contained in:
Cedric BAIL 2008-12-19 17:55:57 +00:00
parent a38ab7590d
commit 5383cabf2b
2 changed files with 5 additions and 3 deletions

View File

@ -125,9 +125,9 @@ EAPI Eina_Accessor *eina_array_accessor_new (const Eina_Array *array);
* @endcode
*/
#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
for (index = 0, iterator = (array)->data, item = iterator != NULL ? *(iterator) : NULL; \
index < eina_array_count_get(array); \
++(index), item = *(++(iterator)))
for (index = 0, iterator = (array)->data; \
(index < eina_array_count_get(array)) && ((item = *((iterator)++))); \
++(index))
#include "eina_inline_array.x"

View File

@ -59,6 +59,8 @@ EAPI Eina_Bool eina_array_grow(Eina_Array *array);
static inline Eina_Bool
eina_array_push(Eina_Array *array, const void *data)
{
if (!data) return EINA_FALSE;
if (UNLIKELY((array->count + 1) > array->total))
if (!eina_array_grow(array)) return EINA_FALSE;