Text3d: add assert's to check the selection and length are valid
authorCampbell Barton <ideasman42@gmail.com>
Sun, 29 Dec 2013 12:16:02 +0000 (23:16 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 29 Dec 2013 12:16:02 +0000 (23:16 +1100)
source/blender/blenkernel/intern/font.c
source/blender/editors/curve/editfont.c

index 16ffd0eea3ab1420e3da840f1157915810cd5176..63095091fa6ff42b7b5b7c6065d37ca2746c8985 100644 (file)
@@ -463,6 +463,10 @@ int BKE_vfont_select_get(Object *ob, int *start, int *end)
        
        if (cu->editfont == NULL || ob->type != OB_FONT) return 0;
 
+       BLI_assert(cu->selstart >= 0 && cu->selstart <= cu->len + 1);
+       BLI_assert(cu->selend   >= 0 && cu->selend   <= cu->len + 1);
+       BLI_assert(cu->pos      >= 0 && cu->pos      <= cu->len);
+
        if (cu->selstart == 0) return 0;
        if (cu->selstart <= cu->selend) {
                *start = cu->selstart - 1;
index 440ded669c097c1fbfab5e0793d39435aa2b5d67..d5b6fe847646f57f75a52037f9083c6e79a85804 100644 (file)
@@ -237,6 +237,8 @@ static void update_string(Curve *cu)
 
        /* Copy the wchar to UTF-8 */
        BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, len + 1);
+
+       BLI_assert(len == cu->len);
 }
 
 static int insert_into_textbuf(Object *obedit, uintptr_t c)