Fix #129167: Operator search can hang for some operator names
RNA label & description truncation could cause invalid UTF8 which caused BLI_string_search to hang. Resolve by ensuring truncation of RNA descriptions & labels never truncates a multi-byte sequences. The issue with BLI_string_search would still be good to resolve but can be handled separately.
This commit is contained in:
committed by
Philipp Oeser
parent
3a29a6ba6b
commit
a7e18ee945
@@ -1328,7 +1328,7 @@ static void rna_Panel_bl_description_set(PointerRNA *ptr, const char *value)
|
||||
Panel *data = (Panel *)(ptr->data);
|
||||
char *str = (char *)data->type->description;
|
||||
if (!str[0]) {
|
||||
BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
|
||||
BLI_strncpy_utf8(str, value, RNA_DYN_DESCR_MAX);
|
||||
}
|
||||
else {
|
||||
BLI_assert_msg(0, "setting the bl_description on a non-builtin panel");
|
||||
@@ -1340,7 +1340,7 @@ static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value)
|
||||
Menu *data = (Menu *)(ptr->data);
|
||||
char *str = (char *)data->type->description;
|
||||
if (!str[0]) {
|
||||
BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
|
||||
BLI_strncpy_utf8(str, value, RNA_DYN_DESCR_MAX);
|
||||
}
|
||||
else {
|
||||
BLI_assert_msg(0, "setting the bl_description on a non-builtin menu");
|
||||
|
||||
@@ -1928,7 +1928,10 @@ static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
|
||||
wmOperator *data = (wmOperator *)(ptr->data);
|
||||
char *str = (char *)data->type->idname;
|
||||
if (!str[0]) {
|
||||
BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
|
||||
/* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
|
||||
* Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
|
||||
* even before registration. */
|
||||
BLI_strncpy_utf8(str, value, OP_MAX_TYPENAME);
|
||||
}
|
||||
else {
|
||||
BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
|
||||
@@ -1940,7 +1943,7 @@ static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
|
||||
wmOperator *data = (wmOperator *)(ptr->data);
|
||||
char *str = (char *)data->type->name;
|
||||
if (!str[0]) {
|
||||
BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
|
||||
BLI_strncpy_utf8(str, value, OP_MAX_TYPENAME);
|
||||
}
|
||||
else {
|
||||
BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
|
||||
@@ -1958,7 +1961,7 @@ static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
|
||||
wmOperator *data = (wmOperator *)(ptr->data); \
|
||||
char *str = (char *)data->type->attr; \
|
||||
if (str && !str[0]) { \
|
||||
BLI_strncpy(str, value, attr_maxncpy); /* utf8 already ensured */ \
|
||||
BLI_strncpy_utf8(str, value, attr_maxncpy); \
|
||||
} \
|
||||
else { \
|
||||
BLI_assert_msg( \
|
||||
|
||||
@@ -221,7 +221,10 @@ static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value)
|
||||
wmGizmo *data = static_cast<wmGizmo *>(ptr->data);
|
||||
char *str = (char *)data->type->idname;
|
||||
if (!str[0]) {
|
||||
BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
|
||||
/* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
|
||||
* Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
|
||||
* even before registration. */
|
||||
BLI_strncpy_utf8(str, value, MAX_NAME);
|
||||
}
|
||||
else {
|
||||
BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
|
||||
@@ -642,7 +645,10 @@ static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value)
|
||||
wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
|
||||
char *str = (char *)data->type->idname;
|
||||
if (!str[0]) {
|
||||
BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
|
||||
/* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
|
||||
* Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
|
||||
* even before registration. */
|
||||
BLI_strncpy_utf8(str, value, MAX_NAME);
|
||||
}
|
||||
else {
|
||||
BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
|
||||
@@ -654,7 +660,7 @@ static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value)
|
||||
wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
|
||||
char *str = (char *)data->type->name;
|
||||
if (!str[0]) {
|
||||
BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
|
||||
BLI_strncpy_utf8(str, value, MAX_NAME);
|
||||
}
|
||||
else {
|
||||
BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
|
||||
|
||||
Reference in New Issue
Block a user