Bug 777304 - Don't use freed pointer after destructor of NS_ConvertUTF16toUTF8. r=bsmedberg

This commit is contained in:
Makoto Kato 2012-07-27 12:13:51 +09:00
parent 4f38c06068
commit 17d5fc9a84
3 changed files with 9 additions and 9 deletions

View File

@ -287,8 +287,8 @@ MediaEngineWebRTCVideoSource::Snapshot(PRUint32 aDuration, nsIDOMFile** aFile)
return NS_ERROR_FAILURE;
}
const char* path = NS_ConvertUTF16toUTF8(*mSnapshotPath).get();
if (vieFile->GetCaptureDeviceSnapshot(mCapIndex, path) < 0) {
NS_ConvertUTF16toUTF8 path(*mSnapshotPath);
if (vieFile->GetCaptureDeviceSnapshot(mCapIndex, path.get()) < 0) {
delete mSnapshotPath;
mSnapshotPath = NULL;
return NS_ERROR_FAILURE;

View File

@ -548,12 +548,12 @@ BluetoothDBusService::SendDiscoveryMessage(const nsAString& aAdapterPath,
nsRefPtr<BluetoothReplyRunnable> runnable = aRunnable;
const char* s = NS_ConvertUTF16toUTF8(aAdapterPath).get();
NS_ConvertUTF16toUTF8 s(aAdapterPath);
if (!dbus_func_args_async(mConnection,
1000,
GetVoidCallback,
(void*)aRunnable,
s,
s.get(),
DBUS_ADAPTER_IFACE,
aMessageName,
DBUS_TYPE_INVALID)) {

View File

@ -443,27 +443,27 @@ AndroidGraphicBuffer::IsBlacklisted()
if (!AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "BOARD", board))
return true;
const char* boardUtf8 = NS_ConvertUTF16toUTF8(board).get();
NS_ConvertUTF16toUTF8 boardUtf8(board);
if (Preferences::GetBool("direct-texture.force.enabled", false)) {
LOG("allowing board '%s' due to prefs override", boardUtf8);
LOG("allowing board '%s' due to prefs override", boardUtf8.get());
return false;
}
if (Preferences::GetBool("direct-texture.force.disabled", false)) {
LOG("disallowing board '%s' due to prefs override", boardUtf8);
LOG("disallowing board '%s' due to prefs override", boardUtf8.get());
return true;
}
// FIXME: (Bug 722605) use something better than a linear search
for (int i = 0; sAllowedBoards[i]; i++) {
if (board.Find(sAllowedBoards[i]) >= 0) {
LOG("allowing board '%s' based on '%s'\n", boardUtf8, sAllowedBoards[i]);
LOG("allowing board '%s' based on '%s'\n", boardUtf8.get(), sAllowedBoards[i]);
return false;
}
}
LOG("disallowing board: %s\n", boardUtf8);
LOG("disallowing board: %s\n", boardUtf8.get());
return true;
}