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 9f0be103139df7a346b0b305b6b214f6f6e2b482
Author: Thanatermesis <[email protected]>
AuthorDate: Mon Feb 23 16:04:40 2026 -0500
fix: Address stringshare leaks, null derefs, and typo in edj_viewer
I have identified several potential issues in src/lib/edj_viewer.c, including memory leaks, potential null pointer dereferences, and logic errors in state management.
1 Memory Leak/Logic Error: In view_part_state_set, when a different part is selected, the old part name and description are leaked because eina_stringshare_del is called
before eina_stringshare_add is used to update the record in the same logic block.
2 Logic Error: The recursion in view_part_state_set could cause issues if not carefully managed. I've streamlined the replacement logic.
3 Null Pointer Safety: Added checks for vd->layout in view_part_state_set to prevent crashes when the layout isn't ready.
4 Typo/Event Handling: Fixed a typo in exe_del_event_cb parameter name (even to event) for consistency and potential compiler warnings.
Here are the fixes:
---
src/lib/edj_viewer.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/lib/edj_viewer.c b/src/lib/edj_viewer.c
index 2337afc..d7053a9 100644
--- a/src/lib/edj_viewer.c
+++ b/src/lib/edj_viewer.c
@@ -63,7 +63,7 @@ static void
view_obj_parts_callbacks_set(view_data *vd);
static Eina_Bool
-exe_del_event_cb(void *data, int type, void *even);
+exe_del_event_cb(void *data, int type, void *event);
/*****************************************************************************/
/* Internal method implementation */
@@ -305,12 +305,12 @@ rect_mouse_move_cb(void *data, Evas *e EINA_UNUSED,
cursor.rely = (float) ((ev->cur.canvas.y - y) / (float) h);
if (vd->view_config_size.w > 0)
- cursor.x = (((double)vd->view_config_size.w) * cursor.relx);
+ cursor.x = (Evas_Coord)(((double)vd->view_config_size.w) * cursor.relx);
else
cursor.x = (ev->cur.canvas.x - x);
if (vd->view_config_size.h > 0)
- cursor.y = (((double)vd->view_config_size.h) * cursor.rely);
+ cursor.y = (Evas_Coord)(((double)vd->view_config_size.h) * cursor.rely);
else
cursor.y = (ev->cur.canvas.y - y);
@@ -938,22 +938,31 @@ void
view_part_state_set(view_data *vd, Eina_Stringshare *part,
Eina_Stringshare *desc, double state)
{
- if (!vd) return;
+ if (!vd || !vd->layout || !vd->file_set_finished) return;
if (!part && !vd->changed_part.part) return;
- if (!vd->file_set_finished) return;
- //reset previous part?
+ /* If the part has changed, reset the previous part to default state
+ and release the previous stringshares to avoid memory leaks. */
if (part != vd->changed_part.part)
{
- view_part_state_set(vd, vd->changed_part.part, "default", 0.0);
- eina_stringshare_del(vd->changed_part.part);
- eina_stringshare_del(vd->changed_part.desc);
+ if (vd->changed_part.part)
+ {
+ edje_edit_part_selected_state_set(vd->layout, vd->changed_part.part,
+ "default", 0.0);
+ eina_stringshare_del(vd->changed_part.part);
+ eina_stringshare_del(vd->changed_part.desc);
+ vd->changed_part.part = NULL;
+ vd->changed_part.desc = NULL;
+ }
}
- edje_edit_part_selected_state_set(vd->layout, part, desc, state);
- vd->changed_part.part = eina_stringshare_add(part);
- vd->changed_part.desc = eina_stringshare_add(desc);
- vd->changed_part.state = state;
+ if (part)
+ {
+ edje_edit_part_selected_state_set(vd->layout, part, desc, state);
+ eina_stringshare_replace(&vd->changed_part.part, part);
+ eina_stringshare_replace(&vd->changed_part.desc, desc);
+ vd->changed_part.state = state;
+ }
}
void
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.