fix for error in strinc.c's BLI_strescape
authorCampbell Barton <ideasman42@gmail.com>
Tue, 6 Sep 2011 07:08:20 +0000 (07:08 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 6 Sep 2011 07:08:20 +0000 (07:08 +0000)
source/blender/blenlib/intern/string.c
source/blender/makesrna/intern/rna_access.c

index c4ed44f0cdb01b260df4baf24a71b98f7692ff70..ae5fa40f3b9aec7e9dab22c8a5c1c0d2b7e6e9f2 100644 (file)
@@ -129,7 +129,7 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
        while(len < maxlen) {
                switch(*src) {
                        case '\0':
-                               break;
+                               goto escape_finish;
                        case '\\':
                        case '"':
 
@@ -154,6 +154,8 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen)
                len++;
        }
 
+escape_finish:
+
        *dst= '\0';
 
        return len;
index 936f2e5e40c3072183e65b1d4b98024a1df49b68..e7d0c5cdec2449267352fca0a884e7e420fc34a4 100644 (file)
@@ -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_esc= MEM_mallocN(sizeof(char)*(length*2+1), "RNA_property_as_string esc");
                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);
                BLI_dynstr_appendf(dynstr, "\"%s\"", buf_esc);
                MEM_freeN(buf_esc);