summaryrefslogtreecommitdiffstats
path: root/cloud_print/gcp20/prototype/printer_state.cc
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 22:43:31 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 22:43:31 +0000
commitfc006cac2085cf5bcc3be856cbf9085fba11aa4b (patch)
treedd03da9ff585773d2dd0558cbbff11da563a73e4 /cloud_print/gcp20/prototype/printer_state.cc
parentd4d844a29b271cabb96ca6d5bdccce8056c1b16f (diff)
downloadchromium_src-fc006cac2085cf5bcc3be856cbf9085fba11aa4b.zip
chromium_src-fc006cac2085cf5bcc3be856cbf9085fba11aa4b.tar.gz
chromium_src-fc006cac2085cf5bcc3be856cbf9085fba11aa4b.tar.bz2
Fix incorrect checking of file_util::WriteFile() return results.
Review URL: https://chromiumcodereview.appspot.com/23865006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print/gcp20/prototype/printer_state.cc')
-rw-r--r--cloud_print/gcp20/prototype/printer_state.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/cloud_print/gcp20/prototype/printer_state.cc b/cloud_print/gcp20/prototype/printer_state.cc
index cf1891d..0c1ab09 100644
--- a/cloud_print/gcp20/prototype/printer_state.cc
+++ b/cloud_print/gcp20/prototype/printer_state.cc
@@ -8,6 +8,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/safe_numerics.h"
#include "base/values.h"
namespace {
@@ -69,8 +70,8 @@ bool SaveToFile(const base::FilePath& path, const PrinterState& state) {
base::JSONWriter::WriteWithOptions(&json,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json_str);
- return !!file_util::WriteFile(path, json_str.data(),
- static_cast<int>(json_str.size()));
+ int size = base::checked_numeric_cast<int>(json_str.size());
+ return (file_util::WriteFile(path, json_str.data(), size) == size);
}
bool LoadFromFile(const base::FilePath& path, PrinterState* state) {