Browse Source

The number returned by vsnprintf contains the actual number of characters. If the message was smaller than the estimated size. It would've created a string with garbage after the null character.

Sandu Liviu Catalin 6 years ago
parent
commit
235fcd9be7
1 changed files with 1 additions and 1 deletions
  1. 1 1
      squirrel/sqapi.cpp

+ 1 - 1
squirrel/sqapi.cpp

@@ -1146,7 +1146,7 @@ begin:
     } else if (r<0) {
         v->_lasterror=SQString::Create(_ss(v),_SC("@failed to generate formatted error message"));
     } else {
-        v->_lasterror=SQString::Create(_ss(v),b,n);
+        v->_lasterror=SQString::Create(_ss(v),b,r);
     }
     return SQ_ERROR;
 }