Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-01-12 08:49:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-12 08:49:33 +0300
commite2e5361eb2e4cb736bd31015eae9c88ba02d26c0 (patch)
treee417dc3f9f6667a9719061fd9ee496e13439a1e9 /source/blender/blenlib/intern/BLI_dynstr.c
parent63018144badeb10c858504c918a3f66047c068b0 (diff)
BLI_dynstr_vappendf() was crashing with strings above 256 chars, this happens with some long reports.
Problem was using va_list value more then once, fix by using va_copy(). Note, va_copy() is c99 spec but only alternative I can see is to turn BLI_dynstr_vappendf() into a macro which calls va_start/end inline.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_dynstr.c')
-rw-r--r--source/blender/blenlib/intern/BLI_dynstr.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index 5b61a86305b..e683c5c016f 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -101,15 +101,21 @@ void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len) {
void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args)
{
char *message, fixedmessage[256];
- int len= 256, maxlen= 65536, retval;
+ int len= sizeof(fixedmessage);
+ const int maxlen= 65536;
+ int retval;
while(1) {
+ va_list args_cpy;
if(len == sizeof(fixedmessage))
message= fixedmessage;
else
message= MEM_callocN(sizeof(char)*(len+1), "BLI_dynstr_appendf");
- retval= vsnprintf(message, len, format, args);
+ /* cant reuse the same args, so work on a copy */
+ va_copy(args_cpy, args);
+ retval= vsnprintf(message, len, format, args_cpy);
+ va_end(args_cpy);
if(retval == -1) {
/* -1 means not enough space, but on windows it may also mean