diff -r 73ea206103e6 -r 43365a9b78a3 userlibandfileserver/fileserver/sfile/sf_local.cpp --- a/userlibandfileserver/fileserver/sfile/sf_local.cpp Wed Jun 23 19:44:53 2010 +0300 +++ b/userlibandfileserver/fileserver/sfile/sf_local.cpp Tue Jul 06 15:50:07 2010 +0300 @@ -320,8 +320,31 @@ // Create the actual proxy drive... CProxyDrive* pD = NULL; TInt r = pF->CreateProxyDrive(pD, NULL); - __ASSERT_ALWAYS(r == KErrNone, User::Panic(_L("CreateProxyDrive Error"), r)); - __ASSERT_ALWAYS(pD != NULL, User::Panic(_L("CreateProxyDrive returned NULL"), -999)); + if (r != KErrNone) + { + delete pD; + return r; + } + if (pD == NULL) + return KErrNoMemory; + + // Create the proxy drive body... which is used to store the library handle + CProxyDriveBody* pBody = new CProxyDriveBody(); + if (pBody == NULL) + { + delete pD; + return KErrNoMemory; + } + pD->iBody = pBody; + + // Re-open the library so that it is safe to call RFs::RemoveProxyDrive() before the proxy drive has been deleted - + // which can happen if the file system is dismounted with open file handles + r = pD->SetAndOpenLibrary(pF->Library()); + if (r != KErrNone) + { + delete pD; + return r; + } iMapping[drive] = i+KMaxLocalDrives; @@ -386,7 +409,12 @@ __ASSERT_ALWAYS(aDrive>=0 && aDrive= KMaxLocalDrives && iProxyDriveMapping[iMapping[aDrive]-KMaxLocalDrives],Fault(EClearProxyDriveMapping2)); TInt idx = iMapping[aDrive]-KMaxLocalDrives; - delete iProxyDriveMapping[idx]; + if (iProxyDriveMapping[idx]->Mount() == NULL) // don't delete if it's still owned by its mount + { + RLibrary lib = iProxyDriveMapping[idx]->GetLibrary(); + delete iProxyDriveMapping[idx]; + lib.Close(); + } iProxyDriveMapping[idx] = NULL; iMapping[aDrive] = KDriveInvalid; }