diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp index 46c1c530c3..51c5aded1d 100644 --- a/src/system/kernel/vm/VMAnonymousCache.cpp +++ b/src/system/kernel/vm/VMAnonymousCache.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -1238,7 +1239,7 @@ public: private: int32 fBestScore; - VolumeInfo fVolumeInfo; + VolumeInfo& fVolumeInfo; }; @@ -1248,14 +1249,24 @@ get_mount_point(KPartition* partition, KPath* mountPoint) if (!mountPoint || !partition->ContainsFileSystem()) return B_BAD_VALUE; + int nameLength = 0; const char* volumeName = partition->ContentName(); - if (!volumeName || strlen(volumeName) == 0) + if (volumeName != NULL) + nameLength = strlen(volumeName); + if (nameLength == 0) { volumeName = partition->Name(); - if (!volumeName || strlen(volumeName) == 0) - volumeName = "unnamed volume"; + if (volumeName != NULL) + nameLength = strlen(volumeName); + if (nameLength == 0) { + volumeName = "unnamed volume"; + nameLength = strlen(volumeName); + } + } - char basePath[B_PATH_NAME_LENGTH]; - int32 len = snprintf(basePath, sizeof(basePath), "/%s", volumeName); + BStackOrHeapArray basePath(nameLength + 1); + if (!basePath.IsValid()) + return B_NO_MEMORY; + int32 len = snprintf(basePath, nameLength + 1, "/%s", volumeName); for (int32 i = 1; i < len; i++) if (basePath[i] == '/') basePath[i] = '-'; @@ -1267,7 +1278,7 @@ get_mount_point(KPartition* partition, KPath* mountPoint) for (int i = 1; ; i++) { if (stat(path, &dummy) != 0) break; - snprintf(path, pathLen, "%s%d", basePath, i); + snprintf(path, pathLen, "%s%d", (char*)basePath, i); } mountPoint->UnlockBuffer();