cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bug in StringBuffer::SetGrowSize

8bit
Protege
Just looking through the SDK I found this possible error.
I could be wrong but I believe there is a missing +1.

LibOVRKernel/Src/Kernel/OVR_String.cpp
void StringBuffer::SetGrowSize(size_t growSize) 
{
if (growSize <= 16)
GrowSize = 16;
else
{
uint8_t bits = Alg::UpperBit(uint32_t(growSize-1));
size_t size = (size_t)1 << bits;
GrowSize = size == growSize ? growSize : size;
}
}


Shouldn't this be
void StringBuffer::SetGrowSize(size_t growSize) 
{
if (growSize <= 16)
GrowSize = 16;
else
{
uint8_t bits = Alg::UpperBit(uint32_t(growSize-1)) + 1;
size_t size = (size_t)1 << bits;
GrowSize = size == growSize ? growSize : size;
}
}

Anyway, just putting this out there in case people are running into seg faults with strings.
-- Assuming I am reading this right, of course --
0 REPLIES 0