yaffs Fix incorrect handling of deletion flag
[yaffs2.git] / yaffs_guts.c
index d55aa95b91e450758bf54474e047f7766100515f..9509dd401a33e5e9eb0a6989f74f733b1cc33d61 100644 (file)
@@ -5624,7 +5624,7 @@ static int yaffs_UnlinkFileIfNeeded(yaffs_Object *in)
 int yaffs_DeleteFile(yaffs_Object *in)
 {
        int retVal = YAFFS_OK;
 int yaffs_DeleteFile(yaffs_Object *in)
 {
        int retVal = YAFFS_OK;
-       int deleted = in->deleted;
+       int deleted; /* Need to cache value on stack if in is freed */
        yaffs_Device *dev = in->myDev;
 
        if (dev->param.disableSoftDelete || dev->param.isYaffs2)
        yaffs_Device *dev = in->myDev;
 
        if (dev->param.disableSoftDelete || dev->param.isYaffs2)
@@ -5637,6 +5637,8 @@ int yaffs_DeleteFile(yaffs_Object *in)
                if (!in->unlinked)
                        retVal = yaffs_UnlinkFileIfNeeded(in);
 
                if (!in->unlinked)
                        retVal = yaffs_UnlinkFileIfNeeded(in);
 
+               deleted = in->deleted;
+
                if (retVal == YAFFS_OK && in->unlinked && !in->deleted) {
                        in->deleted = 1;
                        deleted = 1;
                if (retVal == YAFFS_OK && in->unlinked && !in->deleted) {
                        in->deleted = 1;
                        deleted = 1;