Ticket #2481: 0ad-check.patch

File 0ad-check.patch, 1.1 KB (added by pcpa, 10 years ago)

0ad-check.patch

  • source/lib/allocators/tests/test_headerless.h

     
    114114
    115115        srand(1);
    116116
     117        const size_t maxSize = (size_t)((rand() / (float)RAND_MAX) * poolSize);
     118        const size_t size = std::max((size_t)HeaderlessAllocator::minAllocationSize, round_down(maxSize, HeaderlessAllocator::allocationAlignment));
     119        // (the size_t cast on minAllocationSize prevents max taking a reference to the non-defined variable)
    117120        for(int i = 0; i < 1000; i++)
    118121        {
    119122            // allocate
    120123            if(rand() >= RAND_MAX/2)
    121124            {
    122                 const size_t maxSize = (size_t)((rand() / (float)RAND_MAX) * poolSize);
    123                 const size_t size = std::max((size_t)HeaderlessAllocator::minAllocationSize, round_down(maxSize, HeaderlessAllocator::allocationAlignment));
    124                 // (the size_t cast on minAllocationSize prevents max taking a reference to the non-defined variable)
    125125                void* p = a.Allocate(size);
    126126                if(!p)
    127127                    continue;