cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=cdacc790f7c19baa69d77883c2a1cc1335b5fd50

commit cdacc790f7c19baa69d77883c2a1cc1335b5fd50
Author: Mike Blumenkrantz <zm...@samsung.com>
Date:   Thu Oct 17 10:23:34 2019 -0400

    elm/code: check save file attrs after opening
    
    ensure that they haven't changed between time of check and time of open
    
    CID 1396966
    
    Reviewed-by: Cedric BAIL <cedric.b...@free.fr>
    Differential Revision: https://phab.enlightenment.org/D10440
---
 src/lib/elementary/elm_code_file.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/lib/elementary/elm_code_file.c 
b/src/lib/elementary/elm_code_file.c
index c5d429f639..07e2f927e6 100644
--- a/src/lib/elementary/elm_code_file.c
+++ b/src/lib/elementary/elm_code_file.c
@@ -185,18 +185,17 @@ EAPI void elm_code_file_save(Elm_Code_File *file)
    tmp = _elm_code_file_tmp_path_get(file);
    crchars = elm_code_file_line_ending_chars_get(file, &crlength);
 
-   if (stat(path, &st) != -1)
-     {
-        mode = st.st_mode;
-        have_mode = EINA_TRUE;
-     }
-
    out = fopen(tmp, "w");
    if (out == NULL)
      {
         free(tmp);
         return;
      }
+   if (fstat(fileno(out), &st) != -1)
+     {
+        mode = st.st_mode;
+        have_mode = EINA_TRUE;
+     }
 
    EINA_LIST_FOREACH(file->lines, item, line_item)
      {

-- 


Reply via email to