mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 912465 - Use MsgNewSafeBufferedFileOutputStream instead of NewLocalFileOutputStream in various places. r=ehsan
This commit is contained in:
parent
ad5b86b5ef
commit
6d6385c6cc
@ -153,7 +153,7 @@ NS_IMETHODIMP mozPersonalDictionary::Save()
|
||||
if(NS_FAILED(res)) return res;
|
||||
|
||||
nsCOMPtr<nsIOutputStream> outStream;
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(outStream), theFile, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE ,0664);
|
||||
NS_NewSafeLocalFileOutputStream(getter_AddRefs(outStream), theFile, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE ,0664);
|
||||
|
||||
// get a buffered output stream 4096 bytes big, to optimize writes
|
||||
nsCOMPtr<nsIOutputStream> bufferedOutputStream;
|
||||
@ -171,6 +171,14 @@ NS_IMETHODIMP mozPersonalDictionary::Save()
|
||||
bufferedOutputStream->Write(utf8Key.get(), utf8Key.Length(), &bytesWritten);
|
||||
bufferedOutputStream->Write("\n", 1, &bytesWritten);
|
||||
}
|
||||
nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(bufferedOutputStream);
|
||||
NS_ASSERTION(safeStream, "expected a safe output stream!");
|
||||
if (safeStream) {
|
||||
res = safeStream->Finish();
|
||||
if (NS_FAILED(res)) {
|
||||
NS_WARNING("failed to save personal dictionary file! possible data loss");
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -939,7 +939,7 @@ Preferences::WritePrefFile(nsIFile* aFile)
|
||||
if (safeStream) {
|
||||
rv = safeStream->Finish();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("failed to save prefs file! possible dataloss");
|
||||
NS_WARNING("failed to save prefs file! possible data loss");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ nsBufferedOutputStream::Flush()
|
||||
nsresult rv;
|
||||
uint32_t amt;
|
||||
if (!mStream) {
|
||||
// Stream already cancelled/flushed; probably because of error.
|
||||
// Stream already cancelled/flushed; probably because of previous error.
|
||||
return NS_OK;
|
||||
}
|
||||
rv = Sink()->Write(mBuffer, mFillPoint, &amt);
|
||||
|
Loading…
Reference in New Issue
Block a user