[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55621] trunk/blender/source/blender/ blenkernel/intern/text.c: Fix [#34768] Out of bounds access in console selection.
Shinsuke Irie
irieshinsuke at yahoo.co.jp
Wed Mar 27 10:57:35 CET 2013
Revision: 55621
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55621
Author: irie
Date: 2013-03-27 09:57:34 +0000 (Wed, 27 Mar 2013)
Log Message:
-----------
Fix [#34768] Out of bounds access in console selection.
txt_utf8_column_to_offset(): don't advance the offset anymore if a null character is found.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/text.c
Modified: trunk/blender/source/blender/blenkernel/intern/text.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/text.c 2013-03-27 08:06:07 UTC (rev 55620)
+++ trunk/blender/source/blender/blenkernel/intern/text.c 2013-03-27 09:57:34 UTC (rev 55621)
@@ -804,7 +804,7 @@
int txt_utf8_column_to_offset(const char *str, int column)
{
int offset = 0, pos = 0, col;
- while (pos < column) {
+ while (*(str + offset) && pos < column) {
col = BLI_str_utf8_char_width_safe(str + offset);
if (pos + col > column)
break;
@@ -827,17 +827,6 @@
return len;
}
-static int txt_utf8_width(const char *src)
-{
- int col = 0;
-
- for (; *src; src += BLI_str_utf8_size(src)) {
- col += BLI_str_utf8_char_width(src);
- }
-
- return col;
-}
-
void txt_move_up(Text *text, short sel)
{
TextLine **linep;
@@ -851,8 +840,7 @@
if ((*linep)->prev) {
int column = txt_utf8_offset_to_column((*linep)->line, *charp);
*linep = (*linep)->prev;
- if (column > txt_utf8_width((*linep)->line)) *charp = (*linep)->len;
- else *charp = txt_utf8_column_to_offset((*linep)->line, column);
+ *charp = txt_utf8_column_to_offset((*linep)->line, column);
}
else {
@@ -875,8 +863,7 @@
if ((*linep)->next) {
int column = txt_utf8_offset_to_column((*linep)->line, *charp);
*linep = (*linep)->next;
- if (column > txt_utf8_width((*linep)->line)) *charp = (*linep)->len;
- else *charp = txt_utf8_column_to_offset((*linep)->line, column);
+ *charp = txt_utf8_column_to_offset((*linep)->line, column);
}
else {
txt_move_eol(text, sel);
More information about the Bf-blender-cvs
mailing list