Fix #20245: datablock names allowed entering 22 characters but can

only accept 21.
This commit is contained in:
2009-12-09 18:03:44 +00:00
parent e68dff3e76
commit 1601f297c9
2 changed files with 8 additions and 6 deletions

View File

@@ -1079,9 +1079,9 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
uiStyleFontSet(&style->widget);
origstr= MEM_callocN(sizeof(char)*(data->maxlen+1), "ui_textedit origstr");
origstr= MEM_callocN(sizeof(char)*data->maxlen, "ui_textedit origstr");
BLI_strncpy(origstr, but->drawstr, data->maxlen+1);
BLI_strncpy(origstr, but->drawstr, data->maxlen);
but->pos= strlen(origstr)-but->ofs;
/* XXX solve generic */
@@ -1130,7 +1130,7 @@ static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char asc
changed= ui_textedit_delete_selection(but, data);
len= strlen(str);
if(len < data->maxlen) {
if(len+1 < data->maxlen) {
for(x= data->maxlen; x>but->pos; x--)
str[x]= str[x-1];
str[but->pos]= ascii;
@@ -1365,7 +1365,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
for (y=0; y<strlen(buf); y++)
{
/* add contents of buffer */
if(len < data->maxlen) {
if(len+1 < data->maxlen) {
for(x= data->maxlen; x>but->pos; x--)
str[x]= str[x-1];
str[but->pos]= buf[y];
@@ -1411,8 +1411,8 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
/* retrieve string */
data->maxlen= ui_get_but_string_max_length(but);
data->str= MEM_callocN(sizeof(char)*(data->maxlen+1), "textedit str");
ui_get_but_string(but, data->str, data->maxlen+1);
data->str= MEM_callocN(sizeof(char)*data->maxlen, "textedit str");
ui_get_but_string(but, data->str, data->maxlen);
data->origstr= BLI_strdup(data->str);
data->selextend= 0;

View File

@@ -885,6 +885,7 @@ void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *soft
*precision= (float)fprop->precision;
}
/* this is the max length including \0 terminator */
int RNA_property_string_maxlength(PropertyRNA *prop)
{
StringPropertyRNA *sprop= (StringPropertyRNA*)rna_ensure_property(prop);
@@ -1588,6 +1589,7 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi
return buf;
}
/* this is the length without \0 terminator */
int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
{
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;