netstar pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=9b5af0abfcf0500495d5424327e90969e95313f0

commit 9b5af0abfcf0500495d5424327e90969e95313f0
Author: Al Poole <[email protected]>
Date:   Sat Sep 30 23:59:33 2017 +0100

    edi_scm: fix memory leak.
    
    If cancelling the diff while it's loading can potenitally lose
    the contents of the diff buffer. This patch fixes that...
---
 src/bin/edi_scm_ui.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/bin/edi_scm_ui.c b/src/bin/edi_scm_ui.c
index 80edefa..1ea64e1 100644
--- a/src/bin/edi_scm_ui.c
+++ b/src/bin/edi_scm_ui.c
@@ -12,6 +12,7 @@ typedef struct _Edi_Scm_Ui {
    Eio_Monitor  *monitor;
    Elm_Code     *code;
    const char   *workdir;
+   void         *data;
 
    Eina_Bool results_max;
    Eina_Bool is_configured;
@@ -83,8 +84,6 @@ _edi_scm_ui_screens_message_close_cb(void *data EINA_UNUSED,
    Evas_Object *popup = data;
 
    evas_object_del(popup);
-
-   elm_exit();
 }
 
 static void
@@ -404,6 +403,12 @@ _edi_scm_diff_thread_cancel_cb(void *data, Ecore_Thread 
*thread EINA_UNUSED)
 
    edi_scm->in_progress = EINA_FALSE;
    edi_scm->thread = NULL;
+
+   if (edi_scm->data)
+     {
+        free(edi_scm->data);
+        edi_scm->data = NULL;
+     }
 }
 
 static void
@@ -418,19 +423,19 @@ _edi_scm_diff_thread_end_cb(void *data, Ecore_Thread 
*thread EINA_UNUSED)
 static void
 _edi_scm_diff_thread_cb(void *data, Ecore_Thread *thread)
 {
-   char *text;
    Edi_Scm_Ui *edi_scm = data;
 
    if (edi_scm->in_progress) return;
 
-   text = edi_scm_diff(!edi_scm->results_max);
+   edi_scm->data = edi_scm_diff(!edi_scm->results_max);
 
    edi_scm->in_progress = EINA_TRUE;
    edi_scm->thread = thread;
 
-   _entry_lines_append(thread, edi_scm->code, text);
+   _entry_lines_append(thread, edi_scm->code, edi_scm->data);
 
-   free(text);
+   free(edi_scm->data);
+   edi_scm->data = NULL;
 }
 
 static void
@@ -455,8 +460,8 @@ _edi_scm_ui_refresh(Edi_Scm_Ui *edi_scm)
      }
    else
      {
-       elm_object_disabled_set(edi_scm->commit_button, !staged);
-       elm_entry_editable_set(edi_scm->commit_entry, staged);
+        elm_object_disabled_set(edi_scm->commit_button, !staged);
+        elm_entry_editable_set(edi_scm->commit_entry, staged);
      }
 
    elm_genlist_realized_items_update(edi_scm->list);
@@ -474,6 +479,12 @@ _edi_scm_ui_refresh_cb(void *data EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED, voi
 
    while ((ecore_thread_wait(edi_scm->thread, 0.1)) != EINA_TRUE);
 
+   if (edi_scm->data)
+     {
+        free(edi_scm->data);
+        edi_scm->data = NULL;
+     }
+
    _edi_scm_ui_refresh(edi_scm);
 }
 

-- 


Reply via email to