Mutant_Fruit
14th March 2008, 02:23
static inline int array_non_zero_int( void *v, int i_count )
{
int i;
- uint32_t *x = v;
- i_count /= sizeof(uint32_t);
+ uint64_t *x = v;
+ i_count /= sizeof(uint64_t);
for( i = 0; i < i_count; i++ )
if( x[i] ) return 1;
return 0;
If i_count represents the number of bytes in the array, then there's an issue with that change. Suppose there are 12 bytes in it (3x uint32_t), by performing i_count /= sizeof(uint64_t), you will only actually check the first 8 bytes to see if they are non-zero. The remaining 4 bytes won't be checked.
A check should be performed to ensure that i_count % sizeof(uint64_t) == 0.
{
int i;
- uint32_t *x = v;
- i_count /= sizeof(uint32_t);
+ uint64_t *x = v;
+ i_count /= sizeof(uint64_t);
for( i = 0; i < i_count; i++ )
if( x[i] ) return 1;
return 0;
If i_count represents the number of bytes in the array, then there's an issue with that change. Suppose there are 12 bytes in it (3x uint32_t), by performing i_count /= sizeof(uint64_t), you will only actually check the first 8 bytes to see if they are non-zero. The remaining 4 bytes won't be checked.
A check should be performed to ensure that i_count % sizeof(uint64_t) == 0.