"(smbfs_fake_share_stat): don't access to free'd memory" wasn't needed

Denys Vlasenko vda.linux at googlemail.com
Wed Jul 10 11:54:22 UTC 2013


-        vfs_path_t *vpath = vfs_path_from_str (path);
+        vfs_path_t *vpath;

+        vpath = vfs_path_from_str (path);
         p = smbfs_get_path (&sc, vpath);
         vfs_path_free (vpath);

-        g_free (p);
-        if (p)
+        if (p != NULL)
         {
             memset (buf, 0, sizeof (*buf));
             /*      show this as dir        */
             buf->st_mode =
                 (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR |
S_IXGRP | S_IXOTH) & myumask;
+            g_free (p);
             return 0;
         }
+        g_free (p);
         return -1;



There was no bug.

"free(p); if (p) ..." is a valid code, since it doesn't access memory
pointed to by p, it only looks at the value of the pointer p.



More information about the mc-devel mailing list