diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-05-15 17:08:58 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-05-15 17:14:18 +0300 |
commit | ae9da3786a3ea2e62b1ece7e28628c2dbadf0605 (patch) | |
tree | 00cf155c413f125b12a21ecff907450f39d92a83 /intern/gawain | |
parent | 1ff97bbfff78a0c375fb5256a9d9d37cd3973bbe (diff) |
Gawain: Add assert for maximum attribute name.
Diffstat (limited to 'intern/gawain')
-rw-r--r-- | intern/gawain/gawain/vertex_format.h | 1 | ||||
-rw-r--r-- | intern/gawain/src/vertex_format.c | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/intern/gawain/gawain/vertex_format.h b/intern/gawain/gawain/vertex_format.h index fd210852dce..f5749a366cf 100644 --- a/intern/gawain/gawain/vertex_format.h +++ b/intern/gawain/gawain/vertex_format.h @@ -61,6 +61,7 @@ typedef struct { typedef struct { unsigned attrib_ct; // 0 to 16 (MAX_VERTEX_ATTRIBS) + unsigned name_ct; // total count of active vertex attrib unsigned stride; // stride in bytes, 1 to 256 bool packed; Attrib attribs[MAX_VERTEX_ATTRIBS]; // TODO: variable-size attribs array diff --git a/intern/gawain/src/vertex_format.c b/intern/gawain/src/vertex_format.c index 35c4054ee4b..d103d7a98a6 100644 --- a/intern/gawain/src/vertex_format.c +++ b/intern/gawain/src/vertex_format.c @@ -141,6 +141,7 @@ static const char* copy_attrib_name(VertexFormat* format, const char* name) unsigned VertexFormat_add_attrib(VertexFormat* format, const char* name, VertexCompType comp_type, unsigned comp_ct, VertexFetchMode fetch_mode) { #if TRUST_NO_ONE + assert(format->name_ct < MAX_VERTEX_ATTRIBS); // there's room for more assert(format->attrib_ct < MAX_VERTEX_ATTRIBS); // there's room for more assert(!format->packed); // packed means frozen/locked assert(comp_ct >= 1 && comp_ct <= 4); @@ -163,6 +164,7 @@ unsigned VertexFormat_add_attrib(VertexFormat* format, const char* name, VertexC assert(fetch_mode != KEEP_FLOAT); } #endif + format->name_ct++; // multiname support const unsigned attrib_id = format->attrib_ct++; Attrib* attrib = format->attribs + attrib_id; @@ -186,8 +188,10 @@ void VertexFormat_add_alias(VertexFormat* format, const char* alias) { Attrib* attrib = format->attribs + (format->attrib_ct - 1); #if TRUST_NO_ONE + assert(format->name_ct < MAX_VERTEX_ATTRIBS); // there's room for more assert(attrib->name_ct < MAX_ATTRIB_NAMES); #endif + format->name_ct++; // multiname support attrib->name[attrib->name_ct++] = copy_attrib_name(format, alias); } |