aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkOSFile_stdio.cpp
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-28 21:03:22 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-28 21:03:22 +0000
commit6390c72cfb3e371a774a627d5f496dc67558e119 (patch)
tree8cbe4da51ed2b8d427ce099a429ce806ddddf1e3 /src/ports/SkOSFile_stdio.cpp
parent5370cd969d8f3957e4306068e6195ac1bca3d6cd (diff)
Fix Coverity reports. (Mostly use of uninitialised values.)
CID=537,103419,103631,103632,103633 Initial review: https://codereview.appspot.com/5936047/ Review URL: https://codereview.appspot.com/5935051 git-svn-id: http://skia.googlecode.com/svn/trunk@3534 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkOSFile_stdio.cpp')
-rw-r--r--src/ports/SkOSFile_stdio.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ports/SkOSFile_stdio.cpp b/src/ports/SkOSFile_stdio.cpp
index 764b466878..1254394431 100644
--- a/src/ports/SkOSFile_stdio.cpp
+++ b/src/ports/SkOSFile_stdio.cpp
@@ -36,10 +36,16 @@ size_t sk_fgetsize(SkFILE* f)
{
SkASSERT(f);
- size_t curr = ::ftell((FILE*)f); // remember where we are
+ long curr = ::ftell((FILE*)f); // remember where we are
+ if (curr < 0) {
+ return 0;
+ }
::fseek((FILE*)f, 0, SEEK_END); // go to the end
- size_t size = ::ftell((FILE*)f); // record the size
- ::fseek((FILE*)f, (long)curr, SEEK_SET); // go back to our prev loc
+ long size = ::ftell((FILE*)f); // record the size
+ if (size < 0) {
+ size = 0;
+ }
+ ::fseek((FILE*)f, curr, SEEK_SET); // go back to our prev loc
return size;
}