Permalink
Browse files

Remove size limit on define function.

  • Loading branch information...
acaudwell committed Jul 15, 2012
1 parent 552d01a commit 75c34601b14a103b6330c6ee22a3babfe03b6420
Showing with 11 additions and 2 deletions.
  1. +11 −2 shader.cpp
View
@@ -832,11 +832,20 @@ void ShaderPart::define(const std::string& name, const char *value, ...) {
va_list vl;
char sub[65536];
+ char* buffer = sub;
+
va_start(vl, value);
- vsnprintf(sub, 65536, value, vl);
+ int string_size = vsnprintf(sub, sizeof(sub), value, vl);
+
+ if(string_size > sizeof(sub)) {
+ buffer = new char[string_size];
+ string_size = vsnprintf(buffer, string_size, value, vl);
+ }
va_end(vl);
- defines[name] = sub;
+ defines[name] = buffer;
+
+ if(buffer != sub) delete[] buffer;
}
void ShaderPart::define(const std::string& name) {

0 comments on commit 75c3460

Please sign in to comment.