fix for error in strinc.c's BLI_strescape

This commit is contained in:
Campbell Barton 2011-09-06 07:08:20 +00:00
parent fa32395b33
commit a41f45946f
2 changed files with 4 additions and 2 deletions

@ -129,7 +129,7 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
while(len < maxlen) { while(len < maxlen) {
switch(*src) { switch(*src) {
case '\0': case '\0':
break; goto escape_finish;
case '\\': case '\\':
case '"': case '"':
@ -154,6 +154,8 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
len++; len++;
} }
escape_finish:
*dst= '\0'; *dst= '\0';
return len; return len;

@ -4407,7 +4407,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
buf= MEM_mallocN(sizeof(char)*(length+1), "RNA_property_as_string"); buf= MEM_mallocN(sizeof(char)*(length+1), "RNA_property_as_string");
buf_esc= MEM_mallocN(sizeof(char)*(length*2+1), "RNA_property_as_string esc"); buf_esc= MEM_mallocN(sizeof(char)*(length*2+1), "RNA_property_as_string esc");
RNA_property_string_get(ptr, prop, buf); RNA_property_string_get(ptr, prop, buf);
BLI_strescape(buf_esc, buf, length*2); BLI_strescape(buf_esc, buf, length*2+1);
MEM_freeN(buf); MEM_freeN(buf);
BLI_dynstr_appendf(dynstr, "\"%s\"", buf_esc); BLI_dynstr_appendf(dynstr, "\"%s\"", buf_esc);
MEM_freeN(buf_esc); MEM_freeN(buf_esc);