eio - protect against posible segv on rename with eio
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 7 Jan 2014 08:49:29 +0000 (17:49 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 7 Jan 2014 08:49:29 +0000 (17:49 +0900)
this MIGHT fix T45 but i can't reproduce to confirm, but reading a
backtrace indicates this could have been the issue. it looks like
there is room for a dangling pointer anyway, so fix.

stable release - cherry-pick me!

src/lib/eio/eio_monitor.c

index 247fe7c..53581a4 100644 (file)
@@ -201,7 +201,11 @@ _eio_monitor_rename(Eio_Monitor *monitor, const char *newpath)
   const char *tmp;
 
   /* destroy old state */
-  if (monitor->exist) eio_file_cancel(monitor->exist);
+  if (monitor->exist)
+    {
+       eio_file_cancel(monitor->exist);
+       monitor->exist = NULL;
+    }
 
   if (monitor->backend)
     {
@@ -218,11 +222,15 @@ _eio_monitor_rename(Eio_Monitor *monitor, const char *newpath)
   eina_stringshare_del(tmp);
 
   /* That means death (cmp pointer and not content) */
+  /* this - i think, is wrong. if the paths are the same, we should just
+   * re-stat anyway. imagine the file was renamed and then replaced?
+   * disable this as this was part of a possible crash due to eio.
   if (tmp == monitor->path)
     {
       _eio_monitor_error(monitor, -1);
       return;
     }
+   */
 
   EINA_REFCOUNT_REF(monitor); /* as we spawn a thread for this monitor, we need to refcount specifically for it */