From e69de7d4faf31a81bae5d07ec60d4a3982bddd69 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Mon, 28 Jan 2013 14:34:30 -0800 Subject: [PATCH] Bug 835408 - nsVolume NameStr and MountPointStr noe return nsCString rather than ptr to freed memory. r=jlebar --- dom/system/gonk/nsVolume.cpp | 4 ++-- dom/system/gonk/nsVolume.h | 4 ++-- dom/system/gonk/nsVolumeService.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dom/system/gonk/nsVolume.cpp b/dom/system/gonk/nsVolume.cpp index a0eeefda9ec5..741fcabb6621 100644 --- a/dom/system/gonk/nsVolume.cpp +++ b/dom/system/gonk/nsVolume.cpp @@ -101,12 +101,12 @@ nsVolume::LogState() const { if (mState == nsIVolume::STATE_MOUNTED) { LOG("nsVolume: %s state %s @ '%s' gen %d locked %d", - NameStr(), StateStr(), MountPointStr(), + NameStr().get(), StateStr(), MountPointStr().get(), MountGeneration(), (int)IsMountLocked()); return; } - LOG("nsVolume: %s state %s", NameStr(), StateStr()); + LOG("nsVolume: %s state %s", NameStr().get(), StateStr()); } void nsVolume::Set(const nsVolume* aVolume) diff --git a/dom/system/gonk/nsVolume.h b/dom/system/gonk/nsVolume.h index 2cd3eb09653f..a5bb72677605 100644 --- a/dom/system/gonk/nsVolume.h +++ b/dom/system/gonk/nsVolume.h @@ -60,13 +60,13 @@ public: void LogState() const; const nsString& Name() const { return mName; } - const char* NameStr() const { return NS_LossyConvertUTF16toASCII(mName).get(); } + nsCString NameStr() const { return NS_LossyConvertUTF16toASCII(mName); } int32_t MountGeneration() const { return mMountGeneration; } bool IsMountLocked() const { return mMountLocked; } const nsString& MountPoint() const { return mMountPoint; } - const char* MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint).get(); } + nsCString MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint); } int32_t State() const { return mState; } const char* StateStr() const { return NS_VolumeStateStr(mState); } diff --git a/dom/system/gonk/nsVolumeService.cpp b/dom/system/gonk/nsVolumeService.cpp index bcf673d24c39..c8c945fa9816 100644 --- a/dom/system/gonk/nsVolumeService.cpp +++ b/dom/system/gonk/nsVolumeService.cpp @@ -129,7 +129,7 @@ NS_IMETHODIMP nsVolumeService::BroadcastVolume(const nsAString& aVolName) nsCOMPtr obs = GetObserverService(); NS_ENSURE_TRUE(obs, NS_NOINTERFACE); - DBG("nsVolumeService::BroadcastVolume for '%s'", vol->NameStr()); + DBG("nsVolumeService::BroadcastVolume for '%s'", vol->NameStr().get()); nsString stateStr(NS_ConvertUTF8toUTF16(vol->StateStr())); obs->NotifyObservers(vol, NS_VOLUME_STATE_CHANGED, stateStr.get()); return NS_OK; @@ -291,8 +291,8 @@ public: { MOZ_ASSERT(NS_IsMainThread()); DBG("UpdateVolumeRunnable::Run '%s' state %s gen %d locked %d", - mVolume->NameStr(), mVolume->StateStr(), mVolume->MountGeneration(), - (int)mVolume->IsMountLocked()); + mVolume->NameStr().get(), mVolume->StateStr(), + mVolume->MountGeneration(), (int)mVolume->IsMountLocked()); mVolumeService->UpdateVolume(mVolume); mVolumeService = NULL;