forked from enlightenment/efl
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:
parent
a38ab7590d
commit
5383cabf2b
|
@ -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"
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue