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 09:01:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-12 09:01:07 +0300
commit9a70c609e00f952584a356b4ddc8fa3240438a12 (patch)
tree1e52cd4bd1d6a9907449e6c2efa37a5f287e0d73 /source/blender/blenlib/intern/BLI_dynstr.c
parente2e5361eb2e4cb736bd31015eae9c88ba02d26c0 (diff)
BLI_dynstr_vappendf() was cutting off the last character when allocating strings.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_dynstr.c')
-rw-r--r--source/blender/blenlib/intern/BLI_dynstr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index e683c5c016f..cdf74ae6b5b 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -110,7 +110,7 @@ void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args)
if(len == sizeof(fixedmessage))
message= fixedmessage;
else
- message= MEM_callocN(sizeof(char)*(len+1), "BLI_dynstr_appendf");
+ message= MEM_callocN(sizeof(char) * len, "BLI_dynstr_appendf");
/* cant reuse the same args, so work on a copy */
va_copy(args_cpy, args);
@@ -130,13 +130,14 @@ void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args)
break;
}
}
- else if(retval > len) {
+ else if(retval >= len) {
/* in C99 the actual length required is returned */
if(message != fixedmessage)
MEM_freeN(message);
message= NULL;
- len= retval;
+ /* retval doesnt include \0 terminator */
+ len= retval + 1;
}
else
break;