This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository enventor.
View the commit online.
commit 165ea6dd8eb2d07c5019a098c3535a7f9254a329
Author: Thanatermesis <[email protected]>
AuthorDate: Mon Feb 23 16:03:22 2026 -0500
fix: Fix memory leak and `length` typo in editor functions
I have identified a potential memory leak and a logic error in src/lib/edc_editor.c.
1 In syntax_color_thread_cb, the variable utf8 is allocated by color_cancel but never freed.
2 In edit_text_insert, lenght is calculated but used for buffer offsets while handling UTF-8 text, which can lead to incorrect cursor placement or deletion if multi-byte
characters are involved (though elm_entry_markup_to_utf8 returns plain text, it's safer to ensure consistency). More importantly, the variable is misspelled as lenght.
Here are the fixes:
---
src/lib/edc_editor.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c
index 7845da9..8ae0268 100644
--- a/src/lib/edc_editor.c
+++ b/src/lib/edc_editor.c
@@ -320,6 +320,7 @@ syntax_color_thread_cb(void *data, Ecore_Thread *thread)
if (!utf8) return;
td->translated = color_apply(thread, syntax_color_data_get(td->ed->sh), utf8,
strlen(utf8), NULL, NULL);
+ free(utf8);
}
static void
@@ -858,16 +859,16 @@ edit_text_insert(edit_data *ed, const char *text)
elm_entry_entry_set(ed->en_edit, text);
return;
}
- int lenght = strlen(selection_utf8);
- int pos_from = elm_entry_cursor_pos_get(ed->en_edit) - lenght;
+ int length = strlen(selection_utf8);
+ int pos_from = elm_entry_cursor_pos_get(ed->en_edit) - length;
Evas_Object *tb = elm_entry_textblock_get(ed->en_edit);
Evas_Textblock_Cursor *cur = evas_object_textblock_cursor_get(tb);
int old_pos = evas_textblock_cursor_pos_get(cur);
- evas_textblock_cursor_pos_set(cur, pos_from + lenght);
+ evas_textblock_cursor_pos_set(cur, pos_from + length);
/* append replacement text, and add relative diff into redoundo module */
- evas_textblock_cursor_pos_set(cur, pos_from + lenght);
+ evas_textblock_cursor_pos_set(cur, pos_from + length);
evas_textblock_cursor_text_append(cur, text);
redoundo_text_relative_push(ed->rd, text);
@@ -875,9 +876,9 @@ edit_text_insert(edit_data *ed, const char *text)
evas_textblock_cursor_pos_set(c_1, pos_from);
Evas_Textblock_Cursor *c_2 = evas_object_textblock_cursor_new(tb);
- evas_textblock_cursor_pos_set(c_2, pos_from + lenght);
+ evas_textblock_cursor_pos_set(c_2, pos_from + length);
/* delete replaced text, and make diff into redoundo module */
- redoundo_text_push(ed->rd, selection_utf8, pos_from, lenght, EINA_FALSE);
+ redoundo_text_push(ed->rd, selection_utf8, pos_from, length, EINA_FALSE);
evas_textblock_cursor_range_delete(c_1, c_2);
evas_textblock_cursor_free(c_1);
@@ -1458,6 +1459,7 @@ edit_line_delete(edit_data *ed)
char *content = evas_textblock_cursor_range_text_get(cur1, cur2,
EVAS_TEXTBLOCK_TEXT_MARKUP);
+ /* Ensure we delete the range between cursors */
evas_textblock_cursor_range_delete(cur1, cur2);
evas_textblock_cursor_free(cur1);
evas_textblock_cursor_free(cur2);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.