diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-08 07:46:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-08 07:46:06 +0400 |
commit | b243b4fe4053341b26df698f41c87b80cae8f484 (patch) | |
tree | 7cb59a46b1d5c6c2ec28b8ed292ca9bbca3f7890 /source/blender | |
parent | e781ea79b2616014b2faff3d74a2efaa844a0f44 (diff) |
Fix for inorrect use of BLI_utf8_invalid_strip, add assert to prevent it happening again.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 2 | ||||
-rw-r--r-- | source/blender/editors/util/numinput.c | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index dd2bd4383b6..d1d88002c96 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -4110,7 +4110,7 @@ static void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) { if (seq) { BLI_strncpy_utf8(seq->name + 2, seq_load->name, sizeof(seq->name) - 2); - BLI_utf8_invalid_strip(seq->name + 2, sizeof(seq->name) - 2); + BLI_utf8_invalid_strip(seq->name + 2, strlen(seq->name + 2)); BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq); if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) { diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 225b3c5538f..e565d6e001c 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -137,6 +137,8 @@ int BLI_utf8_invalid_strip(char *str, int length) { int bad_char, tot = 0; + BLI_assert(str[length] == '\0'); + while ((bad_char = BLI_utf8_invalid_byte(str, length)) != -1) { str += bad_char; length -= bad_char; diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 8b98d00b282..78499dac55b 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -131,7 +131,7 @@ void outputNumInput(NumInput *n, char *str) BLI_snprintf(&str[j * ln], ln, "%sNONE%s", cur, cur); } /* We might have cut some multi-bytes utf8 chars (e.g. trailing '°' of degrees values can become only 'A')... */ - BLI_utf8_invalid_strip(&str[j * ln], ln); + BLI_utf8_invalid_strip(&str[j * ln], strlen(&str[j * ln])); } } |