Bug 836455: Sanity-check the result of 'fread()' in nptest.cpp to fix opt build warning. r=bsmedberg
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 11 Feb 2013 10:16:51 -0800
changeset 121473 96c341954032ad826ef7aff5b250c49836bfc826
parent 121472 784b9beebe90f5e0219a66c8a58a222fdd517c58
child 121508 93ba23f414ffec7fdecdff3511e038fd3d877c43
push id24290
push userdholbert@mozilla.com
push dateMon, 11 Feb 2013 18:18:12 +0000
treeherdermozilla-central@96c341954032 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs836455
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 836455: Sanity-check the result of 'fread()' in nptest.cpp to fix opt build warning. r=bsmedberg
dom/plugins/test/testplugin/nptest.cpp
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -1384,17 +1384,21 @@ NPP_StreamAsFile(NPP instance, NPStream*
 
   FILE *file = fopen(fname, "rb");
   if (file) {
     fseek(file, 0, SEEK_END);
     size = ftell(file);
     instanceData->fileBuf = malloc((int32_t)size + 1);
     char* buf = reinterpret_cast<char *>(instanceData->fileBuf);
     fseek(file, 0, SEEK_SET);
-    fread(instanceData->fileBuf, 1, size, file);
+    size_t sizeRead = fread(instanceData->fileBuf, 1, size, file);
+    if (sizeRead != size) {
+      printf("Unable to read data from file\n");
+      instanceData->err << "Unable to read data from file " << fname;
+    }
     fclose(file);
     buf[size] = '\0';
     instanceData->fileBufSize = (int32_t)size;
   }
   else {
     printf("Unable to open file\n");
     instanceData->err << "Unable to open file " << fname;
   }