X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvertexformat.cpp;h=dc8ff23eeaa2a7b52f194ef72c94a11c705d5f77;hb=5172d32d67595ea0b70184fadcfcb8e023cccbc8;hp=e56397e2b088cb93a1204d80027ef875b1c91a73;hpb=b617c5d7b5283ad260a77f01e42e6170cabbc03d;p=libs%2Fgl.git diff --git a/source/vertexformat.cpp b/source/vertexformat.cpp index e56397e2..dc8ff23e 100644 --- a/source/vertexformat.cpp +++ b/source/vertexformat.cpp @@ -31,7 +31,7 @@ VertexFormat::VertexFormat(const VertexFormat &f): { if(f.data) { - data = new unsigned char[f.data[0]/8+8]; + data = new unsigned char[(f.data[0]&~7)+8]; memcpy(data, f.data, f.data[0]+1); } } @@ -41,7 +41,7 @@ VertexFormat &VertexFormat::operator=(const VertexFormat &f) delete[] data; if(f.data) { - data = new unsigned char[f.data[0]/8+8]; + data = new unsigned char[(f.data[0]&~7)+8]; memcpy(data, f.data, f.data[0]+1); } else @@ -94,11 +94,8 @@ VertexFormat operator,(const VertexFormat &f, unsigned i) throw InvalidState("VertexFormat has no components"); VertexFormat r = f; unsigned char *c = r.data+r.data[0]; - if(*c=28) - throw InvalidParameterValue("Generic attribute index out of range"); + if((*c0) || (*c=8) || i>=53) + throw InvalidParameterValue("Vertex component index out of range"); *c += i*4; return r;