This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 83ea3972d971269629b122cd7743c335fe65ebe5
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 7 23:37:30 2026 -0600
eina: converting a value that holds an empty one does not crash
An Eina_Value of type VALUE that holds an empty value (no type) read the
memory of that value in its convert functions, which dereferences the
missing type. An array of values with an empty element crashed in
eina_value_to_string. Converting an empty inner value now fails, as the
conversion of a value that cannot be converted does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/eina/eina_value.c | 5 +++++
src/tests/eina/eina_test_value.c | 23 +++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/src/lib/eina/eina_value.c b/src/lib/eina/eina_value.c
index 4045124775..10be8c0d4d 100644
--- a/src/lib/eina/eina_value.c
+++ b/src/lib/eina/eina_value.c
@@ -3939,6 +3939,9 @@ static Eina_Bool
_eina_value_type_value_convert_to(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
{
const Eina_Value *v = type_mem;
+
+ /* An empty value holds nothing to convert (and has no memory to get). */
+ if (!v->type) return EINA_FALSE;
return eina_value_type_convert_to(v->type, convert, eina_value_memory_get(v), convert_mem);
}
@@ -3946,6 +3949,8 @@ static Eina_Bool
_eina_value_type_value_convert_from(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
{
Eina_Value *v = type_mem;
+
+ if (!v->type) return EINA_FALSE;
return eina_value_type_convert_from(v->type, convert, eina_value_memory_get(v), convert_mem);
}
diff --git a/src/tests/eina/eina_test_value.c b/src/tests/eina/eina_test_value.c
index 31382368e5..31293f487f 100644
--- a/src/tests/eina/eina_test_value.c
+++ b/src/tests/eina/eina_test_value.c
@@ -2087,6 +2087,28 @@ EFL_START_TEST(eina_value_test_dup_array)
}
EFL_END_TEST
+EFL_START_TEST(eina_value_test_array_of_values_with_an_empty_one)
+{
+ Eina_Value *array, empty = EINA_VALUE_EMPTY, number;
+ char *str;
+
+ /* An array of values holding an empty one converts to a string. */
+ array = eina_value_array_new(EINA_VALUE_TYPE_VALUE, 0);
+ fail_unless(array != NULL);
+ fail_unless(eina_value_setup(&number, EINA_VALUE_TYPE_INT));
+ fail_unless(eina_value_set(&number, 7));
+ fail_unless(eina_value_array_pappend(array, &number));
+ fail_unless(eina_value_array_pappend(array, &empty));
+ fail_unless(eina_value_array_pappend(array, &number));
+ eina_value_flush(&number);
+
+ str = eina_value_to_string(array);
+ fail_unless(str != NULL);
+ free(str);
+ eina_value_free(array);
+}
+EFL_END_TEST
+
EFL_START_TEST(eina_value_test_array)
{
Eina_Value *value, other;
@@ -3135,6 +3157,7 @@ eina_test_value(TCase *tc)
tcase_add_test(tc, eina_value_test_convert_float);
// TODO: other converters...
tcase_add_test(tc, eina_value_test_array);
+ tcase_add_test(tc, eina_value_test_array_of_values_with_an_empty_one);
tcase_add_test(tc, eina_value_test_dup_array);
tcase_add_test(tc, eina_value_test_list);
tcase_add_test(tc, eina_value_test_list_insert);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.