ajwillia-ms pushed a commit to branch master.

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

commit d380f0f6d329ff4ccdb076d064359a234ba563c9
Author: Andy Williams <a...@andywilliams.me>
Date:   Mon May 18 15:45:28 2015 +0100

    editor: fix memory corruption when opening new win
    
    Fixes issue when a file opened to a new window could not then
    be focussed or re-loaded after the window is closed
---
 src/bin/edi_main.c              | 2 +-
 src/bin/mainview/edi_mainview.c | 7 ++++++-
 src/lib/edi_path.c              | 5 +++--
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c
index 390ee77..de963fb 100644
--- a/src/bin/edi_main.c
+++ b/src/bin/edi_main.c
@@ -451,7 +451,7 @@ _tb_new_create_cb(void *data,
 
    fclose(fopen(path, "w"));
    _edi_filepanel_reload();
-   edi_mainview_open_path(eina_stringshare_add(path));
+   edi_mainview_open_path(path);
 
    evas_object_del(_edi_new_popup);
    free((char*)path);
diff --git a/src/bin/mainview/edi_mainview.c b/src/bin/mainview/edi_mainview.c
index 89263f7..f2979b6 100644
--- a/src/bin/mainview/edi_mainview.c
+++ b/src/bin/mainview/edi_mainview.c
@@ -145,7 +145,7 @@ _edi_mainview_item_add(Edi_Path_Options *path, const char 
*mime, Elm_Object_Item
    Edi_Mainview_Item *item;
 
    item = malloc(sizeof(Edi_Mainview_Item));
-   item->path = path->path;
+   item->path = eina_stringshare_add(path->path);
    item->editortype = path->type;
    item->mimetype = mime;
    item->tab = tab;
@@ -425,6 +425,8 @@ edi_mainview_open_window_path(const char *path)
         elm_naviframe_item_pop(nf);
         elm_object_item_del(elm_toolbar_selected_item_get(tb));
         _edi_mainview_items = eina_list_remove(_edi_mainview_items, it);
+
+        eina_stringshare_del(it->path);
         free(it);
      }
 
@@ -445,6 +447,8 @@ edi_mainview_open_window(Edi_Path_Options *options)
         elm_naviframe_item_pop(nf);
         elm_object_item_del(elm_toolbar_selected_item_get(tb));
         _edi_mainview_items = eina_list_remove(_edi_mainview_items, it);
+
+        eina_stringshare_del(it->path);
         free(it);
      }
 
@@ -503,6 +507,7 @@ edi_mainview_close()
    elm_object_item_del(elm_toolbar_selected_item_get(tb));
    _edi_mainview_items = eina_list_remove(_edi_mainview_items, item);
 
+   eina_stringshare_del(item->path);
    free(item);
 }
 
diff --git a/src/lib/edi_path.c b/src/lib/edi_path.c
index 3f84398..591b0ce 100644
--- a/src/lib/edi_path.c
+++ b/src/lib/edi_path.c
@@ -20,7 +20,7 @@ edi_path_options_create(const char *input)
    pos1 = strstr(path, ":");
    if (pos1)
      {
-        path = eina_stringshare_add_length(path, strlen(path) - strlen(pos1));
+        ret->path = eina_stringshare_add_length(path, strlen(path) - 
strlen(pos1));
         pos1++;
         pos2 = strstr(pos1, ":");
         if (pos2)
@@ -34,8 +34,9 @@ edi_path_options_create(const char *input)
              line = atoi(pos1);
           }
      }
+   else
+     ret->path = eina_stringshare_add(path);
 
-   ret->path = path;
    ret->line = line;
    ret->character = col;
 

-- 


Reply via email to