Commit f924eff4 authored by paivanof@gmail.com's avatar paivanof@gmail.com

Fix error checking in VisitedLinkMaster.

Avoid crashes when visited links database cannot be opened.

BUG=61102, 141044

Review URL: https://chromiumcodereview.appspot.com/10826297

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151870 0039d316-1c4b-4281-b951-d872f2087c98
parent 318ee398
...@@ -94,21 +94,24 @@ static bool WriteToFile(FILE* file, ...@@ -94,21 +94,24 @@ static bool WriteToFile(FILE* file,
// is used because file may still not be opened by the time of scheduling // is used because file may still not be opened by the time of scheduling
// the task for execution. // the task for execution.
void AsyncWrite(FILE** file, int32 offset, const std::string& data) { void AsyncWrite(FILE** file, int32 offset, const std::string& data) {
WriteToFile(*file, offset, data.data(), data.size()); if (*file)
WriteToFile(*file, offset, data.data(), data.size());
} }
// Truncates the file to the current position asynchronously on a background // Truncates the file to the current position asynchronously on a background
// thread. Double pointer to FILE is used because file may still not be opened // thread. Double pointer to FILE is used because file may still not be opened
// by the time of scheduling the task for execution. // by the time of scheduling the task for execution.
void AsyncTruncate(FILE** file) { void AsyncTruncate(FILE** file) {
base::IgnoreResult(TruncateFile(*file)); if (*file)
base::IgnoreResult(TruncateFile(*file));
} }
// Closes the file on a background thread and releases memory used for storage // Closes the file on a background thread and releases memory used for storage
// of FILE* value. Double pointer to FILE is used because file may still not // of FILE* value. Double pointer to FILE is used because file may still not
// be opened by the time of scheduling the task for execution. // be opened by the time of scheduling the task for execution.
void AsyncClose(FILE** file) { void AsyncClose(FILE** file) {
base::IgnoreResult(fclose(*file)); if (*file)
base::IgnoreResult(fclose(*file));
free(file); free(file);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment