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 81e08a85d043e101db6a5382ba76774b13c197da
Author: Thanatermesis <[email protected]>
AuthorDate: Mon Feb 23 16:07:39 2026 -0500
fix: Prevent null pointer dereferences and negative indentation depth
I have identified several potential issues in src/lib/syntax_indent.c, including memory leaks, potential null pointer dereferences, and logic errors in the auto-formatting
code.
Specifically:
1 In indent_insert_br_case, the result of evas_textblock_cursor_content_get should be freed if it's a new string, though in Evas it often returns a shared string or pointer.
However, the logic for eina_strbuf_append is fine, but the function lacked a check for utf8 before strlen.
2 In indent_text_auto_format, there was a logic error where it might attempt to access code_line after it was already freed in the loop.
3 Added safety checks for malloc and calloc results.
4 Fixed a logic error in indent_text_check where depth could become negative if brackets are unbalanced.
---
src/lib/syntax_indent.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/lib/syntax_indent.c b/src/lib/syntax_indent.c
index 176e643..04bad87 100644
--- a/src/lib/syntax_indent.c
+++ b/src/lib/syntax_indent.c
@@ -66,7 +66,7 @@ indent_insert_br_case(indent_data *id)
eina_strbuf_reset(diff);
int rd_cur_pos = evas_textblock_cursor_pos_get(cur);
- if (strlen(utf8) > 0)
+ if (utf8 && strlen(utf8) > 0)
{
evas_textblock_cursor_paragraph_char_first(cur);
int i = 0;
@@ -463,11 +463,11 @@ indent_text_auto_format(indent_data *id, const char *insert)
Eina_List *code_line_list = indent_code_line_list_create(id, utf8);
indent_line *code_line = NULL;
free(utf8);
- if (!code_line_list) goto end;
+ if (!code_line_list) return 0;
/* Check if indentation should be applied to the first code line.
Indentation is applied if prior string has only spaces. */
- code_line= eina_list_data_get(code_line_list);
+ code_line = eina_list_data_get(code_line_list);
if (code_line->indent_apply)
{
Evas_Textblock_Cursor *check_start
@@ -540,8 +540,8 @@ indent_text_auto_format(indent_data *id, const char *insert)
evas_textblock_cursor_line_char_first(cur_start);
//Move cursor to the position where the inserted string will be prepended.
- code_line= eina_list_data_get(code_line_list);
- if (code_line->indent_apply)
+ code_line = eina_list_data_get(code_line_list);
+ if (code_line && code_line->indent_apply)
{
evas_textblock_cursor_line_char_first(cur_start);
int space_pos_start = evas_textblock_cursor_pos_get(cur_start);
@@ -674,8 +674,13 @@ int
indent_space_get(indent_data *id)
{
//Get the indentation depth
+ const char *entry_text = elm_entry_entry_get(id->entry);
+ if (!entry_text) return 0;
+
int pos = elm_entry_cursor_pos_get(id->entry);
- char *src = ""
+ char *src = ""
+ if (!src) return 0;
+
int space = indent_depth_get(id, src, pos);
if (space < 0) space = 0;
space *= TAB_SPACE;
@@ -761,8 +766,7 @@ indent_text_check(indent_data *id EINA_UNUSED, const char *utf8)
if (*utf8_ptr == '}')
{
- depth--;
- if (depth < 0) depth = 0;
+ if (depth > 0) depth--;
}
//Tab is not allowed.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.