Mikko Rasa <[email protected]> writes: > + /* check that the buffer is large enough to hold the indices, > + * reallocate if necessary. > + */ > + hr = IWineD3DBuffer_GetDesc(This->indexbuffer, &desc); > + if(desc.Size < IndexCount * sizeof(WORD)) > + { > + UINT size = desc.Size; > + IWineD3DBuffer *buffer; > + IUnknown *parent; > + > + while(size < IndexCount * sizeof(WORD)) > + { > + size <<= 1; > + /* We keep adding zero bits to the right, so an overflow > + * will eventually result in all zeroes. Detect this to > + * avoid infinite loop. > + */ > + if(!size) > + { > + ERR("UINT overflow while trying to grow indexbuffer to hold > %u indices\n", IndexCount); > + LeaveCriticalSection(&ddraw_cs); > + return D3DERR_TOOMANYPRIMITIVES; > + } > + }
A simple "size = max(desc.Size*2,IndexCount*sizeof(WORD))" would do just as well. -- Alexandre Julliard [email protected]
